doctype html html head title Slim Examples meta name="keywords" content="template language" body h1 Markup examples #content.example1 p Nest by indentation = yield - unless items.empty? table - for item in items do tr td = item.name td = item.price - else p No items found #footer | Copyright © 2010 Andrew Stone = render 'tracking_code' script | $(content).do_something();
| , . "" . ' , . - Haml, , , <% ... %> = <%= ... %>, html =' , . == , " ", escape_html ==' , , . / . html . /! html (<!-- -->), .
blockquote id="quote-#{@quote.id}" class="quote" p class="title" = @quote.title p style="padding:1em;" = @quote.body
%blockquote{:id => "quote-#{@quote.id}", :class => "quote"} %p{:class="title"}= @quote.title %p{:style => "padding:1em;"}= @quote.body
/ . , , Haml' #nav.top div id="nav" class="top" / h1 class=page_header_class = page_header h1{class=page_header_class} = page_header h1[class=page_header_class] = page_header h1(class=page_header_class) = page_header
# , . a href="#{url_for @user}" = @user.name # "#{...}" a href=url_for(@user) = @user.name
option value="Slim" selected=option_selected?("Slim") # -> <option value="Slim"></option>
body h1 , #{current_user.name} | #{{content}} , escape_html.
# /.comments - @comments.each do |comment| == render comment
Slim::Engine.set_default_options :sections => true
/ false empty?, h1 - article h1 = title
/ , article false empty? -! article p
/ If article.respond_to?(:title) - article / article.send(:title) h1 = title
/ If article.respond_to?(:has_key?) and article.has_key?(:title) - article / article[:title] h1 = title
/ If article.instance_variable_defined?(@title) - article / article.instance_variable_get @title h1 = title
# Linux + Ruby 1.9.2, 1000 iterations user system total real (1) erb 0.680000 0.000000 0.680000 ( 0.810375) (1) erubis 0.510000 0.000000 0.510000 ( 0.547548) (1) fast erubis 0.530000 0.000000 0.530000 ( 0.583134) (1) slim 4.330000 0.020000 4.350000 ( 4.495633) (1) haml 4.680000 0.020000 4.700000 ( 4.747019) (1) haml ugly 4.530000 0.020000 4.550000 ( 4.592425) (2) erb 0.240000 0.000000 0.240000 ( 0.235896) (2) erubis 0.180000 0.000000 0.180000 ( 0.185349) (2) fast erubis 0.150000 0.000000 0.150000 ( 0.154970) (2) slim 0.050000 0.000000 0.050000 ( 0.046685) (2) haml 0.490000 0.000000 0.490000 ( 0.497864) (2) haml ugly 0.420000 0.000000 0.420000 ( 0.428596) (3) erb 0.030000 0.000000 0.030000 ( 0.033979) (3) erubis 0.030000 0.000000 0.030000 ( 0.030705) (3) fast erubis 0.040000 0.000000 0.040000 ( 0.035229) (3) slim 0.040000 0.000000 0.040000 ( 0.036249) (3) haml 0.160000 0.000000 0.160000 ( 0.165024) (3) haml ugly 0.150000 0.000000 0.150000 ( 0.146130) (4) erb 0.060000 0.000000 0.060000 ( 0.059847) (4) erubis 0.040000 0.000000 0.040000 ( 0.040770) (4) slim 0.040000 0.000000 0.040000 ( 0.047389) (4) haml 0.190000 0.000000 0.190000 ( 0.188837) (4) haml ugly 0.170000 0.000000 0.170000 ( 0.175378) 1. . , slow=1. 2. . . Ruby . API . 3. . , , Ruby . , . 4. Tilt-. Tilt, Sinatra, Ramaze and Camping.
# Slim gem 'slim' # Slim Scaffold' gem 'slim-rails'
Then you need to register in the console bundle install to install the selected gems.Source: https://habr.com/ru/post/128645/
All Articles