Questions tagged [slim-lang]

Slim is a lightweight template engine for Ruby whose goal is reduce the syntax to the essential parts without becoming cryptic.

Slim is a template language whose goal is reduce the syntax to the essential parts without becoming cryptic.

The initial design of Slim is what you see on the home page. It started as an exercise to see how much could be removed from a standard html template (<, >, closing tags, etc...). As more people took an interest in Slim, the functionality grew and so did the flexibility of the syntax.

Slim will strive to maintain simplicity, but not everyone's definition of a readable syntax is the same. The docs will show you the options.

Slim uses Temple and Tilt. If you want to learn how Slim works, you'll need to study these projects.

Source: Slim-lang.com (About)

681 questions
0
votes
1 answer

rails can‘t use code to generate form

my view code(index.slim) is this: -form_tag do Form contents but this doesn't generate a form,nothing I will get,why? my rails version is 3.2.14 .and I just generate this project through rails new blog to study rails.
HXH
  • 1,643
  • 4
  • 19
  • 31
0
votes
1 answer

Using String.split inline to set CSS classes in the view

In my model I have a field type string called god_type. Example: Ice,Fire Ranged,Cannon Fire,Ranged I'm going to be using Isotope to filter these models based on their god_type. I need the output HTML to look like:
sergserg
  • 21,716
  • 41
  • 129
  • 182
0
votes
1 answer

How to make web form appear after previous web form has data entered into it?

I'm looking to make a second web form appear after the first web form has something entered into it. I'm currently using a sinatra set up with slim as the templating engine, and pure javascript. input#topic value="Enter topic" onfocus="this.value =…
Adam Bronfin
  • 1,209
  • 3
  • 27
  • 43
0
votes
1 answer

AngularJS, dynamically loaded view can't see corresponding controller

I trying to write app using angularjs and bootsrap. I use RoR on server, SLIM and CoffeeScript for templates and assets. This is my index file: doctype html lang="en" ng-app='my_server' head meta charset="utf-8" meta…
zhulik
  • 133
  • 4
0
votes
2 answers

rails slim very simple questions

I'm new to slim and there are little things that I don't understand and I don't find answers in the documentation. linebreak - How can I add this at the end of a line? For example: <%= name %>
<%= address %>
How can I combine pure html…
ndemoreau
  • 3,849
  • 4
  • 43
  • 55
0
votes
1 answer

Convert slim to ERB

I am making my first steps in ruby and I am trying to learn how to use Sinatra. In a relevant book I found this example view written in Slim. h1 Songs a href="/songs/new" Create a new song - if @songs.any? ul#songs -@songs.each do |song| …
magmike
  • 473
  • 1
  • 5
  • 18
0
votes
1 answer

How do I stop slim template rendering half way?

I am using Sinatra and slim. In one slim template I would like to stop render if a variable is true. Code like this: - if @lock p.alert this page is locked. - stop_render I tried to use return and that just generated a empty page.…
Kurt Liu
  • 610
  • 2
  • 8
  • 15
0
votes
2 answers

Fixing redundancy in Slim if else statement

I have the following if else statement in my slim file - if x == 0 div Some cool title here - else div A different cool title goes here Which is fine, however I want to have some child tags inside the divs - if x == 0 div Some cool title here …
thank_you
  • 11,001
  • 19
  • 101
  • 185
0
votes
3 answers

Inheritance in Slim template language

With PHP using Twig I can do something like this: layout.twig {% block content %}{% endblock %} form.twig {% extends "layout.twig" %} {% block content %}
{% block form %}{% endblock %}
{%…
user1569115
0
votes
1 answer

slim - unexpected keyword_ensure, expecting end-of-input

I'm using Slim for my views and have this: / = render 'alphabet' div class="house-list" data-pjax-container="true" - @houses.each do |house| = link_to house_path(house) .picture = image_tag…
rctneil
  • 7,016
  • 10
  • 40
  • 83
0
votes
1 answer

Slim and Rails issue

Basically I am trying to get this output in Rails and Slim: myname This is what I have so far: = link_to 'myname', controller: :pages, action: :home Obviously it…
rctneil
  • 7,016
  • 10
  • 40
  • 83
0
votes
1 answer

PHP possibilities in Slim Template language for Ruby

In PHP I can do this:
"> "; ?> It is incredibly convenient. I can break a string in any place, between any quotes, between any HTML symbols, just wherever I want. And I need to…
Green
  • 28,742
  • 61
  • 158
  • 247
0
votes
1 answer

Slim templates: Can't render a template, get syntax error

I'd like to use full html syntax with Slim. I don't want the cryptography they offer. But I think it's impossible. Here's my html code and Slim throws an error. The target: I want not to output an additional class of div element if some condition is…
Green
  • 28,742
  • 61
  • 158
  • 247
0
votes
1 answer

Bootstrap highlight selected item in a nav list

So I am using bootstrap together with slim to build some navigable pages. Am stuck on highlighting the selected item on the list as "activate" class applied. I did find something called affix or scrollspy but these are different from what I need to…
William Gu
  • 852
  • 1
  • 8
  • 14
0
votes
1 answer

Strange "file not found" error in ruby sinatra web app

I'm creating a sinatra web app with a mongodb database. I use mongomapper to do the mappings. The web server is thin and I'm using slim as a templating language. file ./config/config.ru: $_DB_SERVER = "localhost" $_APP_PATH =…
MarioDS
  • 12,895
  • 15
  • 65
  • 121