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
14
votes
1 answer

Slim Templating: Is it possible to put two elements on the same line?

I often want to nest elements, such as the following navigation: ul li a(href="#") link Name li a(href="#") link Name li a(href="#") link Name Is is possible to put li and a on the same line? Some syntax like li > a would be…
wesbos
  • 25,839
  • 30
  • 106
  • 143
14
votes
2 answers

form_for method using slim

I have looked at the documentation of slim, and I still can't figure out how to do this in slim: <%= form_for([@post, @post.comments.build]) do |f| %>
<%= f.label :commenter %>
<%= f.text_field :commenter %> …
AlexBrand
  • 11,971
  • 20
  • 87
  • 132
13
votes
1 answer

In Slim templates, HTML comments on separate lines are rendered on the same line

When writing HTML comments in SLIM: /! The first line of comments /! The second line of comments The output becomes All the other generated HTML is properly formatted and…
Steven Yuan
  • 369
  • 2
  • 3
  • 13
13
votes
3 answers

Using tags such as bold or italic in slim?

Let's say I have this code in HTML:

Lorem ipsum, volutpat. Ut wisi enim ad minim veniam.

How would I convert that to slim? Throughout all of Slim's documentation, it never once mentions bold, italic, or any other inline elements. I…
Ty Strong
  • 227
  • 2
  • 10
13
votes
3 answers

Slim Line breaks and formatting

I am using slim for templating and ruby on rails(just started using them). The only problem I am facing is: there is no formatting for the html rendered. i.e no line breaks, no indentation. I can understand it can be a little tricky for slim to…
SoWhat
  • 5,564
  • 2
  • 28
  • 59
11
votes
4 answers

how to install slim tm bundle in sublime2

I would like to install the slim textmate bundle to sublime2. I went to this link slim textmate bundle I cloned it to the pristinepackage(as per the nettuts website) but nothing happened.. What am I missing?.
coool
  • 8,085
  • 12
  • 60
  • 80
11
votes
4 answers

How can I convert html.slim files to html or html.erb?

I need to convert the html.slim files in my Ruby on Rails application to html.erb. Is there any easy way to do it? I tried many options listed in Stack Overflow and other sites. But nothing worked for me. I found a converter…
Aswathy
  • 654
  • 1
  • 12
  • 26
11
votes
2 answers

horizontally scrollable one line gallery with css

I would like a horizontally scrollable gallery like the one on the image. My current markup is this (it is slim.): .col-xs-12 .row-fluid.clearfix ul.ace-thumbnails - @equipment_uses.each do |gear| = content_tag_for(:li, gear) do …
Boti
  • 3,275
  • 1
  • 29
  • 54
11
votes
7 answers

Convert ERB template to SLIM

Many of my views are SLIM templates and I wish to add a vote_form partial to my app. How would I convert this partial view from ERB to SLIM? Votes: <%= voteable.votes_for - voteable.votes_against %> <%= form_tag…
Khmaies Guesmi
  • 111
  • 1
  • 1
  • 4
10
votes
3 answers

How to set HTML5 attributes like 'required' using a Slim template

I m laying out a form using the Slim template language and want to add the required attribute to my input. input#first_name(required name="first_name" type="text" pattern="^[A-Z][a-z]+$") However the HTML that is generated from this ends up being …
Dave Sag
  • 13,266
  • 14
  • 86
  • 134
10
votes
3 answers

How do I wrap span tags in a link_to in slim?

li = link_to 'Account', '#account', data: { toggle: 'tab' } I need span tags around 'Account'.
Aen Tan
  • 3,305
  • 6
  • 32
  • 52
9
votes
4 answers

how to give whitespace in ruby slim

I want to seperate currency and total with whitespace. Please suggest me a solution Any help would be appreciated. p strong Total: span = @order.currency = humanized_money_with_symbol @order.total_paisas/100
SreRoR
  • 1,151
  • 1
  • 17
  • 44
9
votes
2 answers

Nesting a text inside a tag in slim

How do I nest the 'Featured' text inside the a tag, given the span, the text, and the other span are siblings? li a href="#" class="selected" span class="icon-before" Featured span class="icon-after"
Marek Příhoda
  • 11,108
  • 3
  • 39
  • 53
8
votes
2 answers

Slim templates on Ruby on Rails, what are best practices

I have trouble understanding basic Slim syntax. First question, how to do you enter new line (line break)? Second request, could you please rewrite the following snippet, I suspect I didn't do it easy way? - provide(:title, @course.title) …
B.I.
  • 706
  • 3
  • 9
  • 19
8
votes
1 answer

Controlling the existence of an attribute

I have a problem with the Slim template engine in a Sinatra project. I have an edit form to be filled when the route is triggered. There is an issue with HTML select option. I need something like this when the edit form is loaded. Notice that Mrs.…
Ziyan Junaideen
  • 3,270
  • 7
  • 46
  • 71
1
2
3
45 46