Sep 10, 2011

Yes, Slim is speedy

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


Slim is a fast, lightweight templating engine with support for Rails 3. It has been tested on Ruby 1.9.2 and Ruby/REE 1.8.7.

Slim's core syntax is guided by one thought: "What's the minimum required to make this work".

As more people have contributed to Slim, there have been optional syntax additions influenced from their use of Haml and Jade. The Slim team is open to these optional additions because we know beauty is in the eye of the beholder.

Slim uses Temple for parsing/compilation and is also integrated into Tilt, so it can be used together with Sinatra or plain Rack.

Sample View:

doctype html
    title Slim Examples
    meta name="keywords" content="template language"

    h1 Markup examples
      p Nest by indentation

    = yield

    - unless items.empty?
        - for item in items do
            td =
            td = item.price
    - else
      p No items found

      | Copyright © 2010 Andrew Stone

    = render 'tracking_code'

      | $(content).do_something();

No comments:

Post a Comment