Sass makes CSS fun again.
Fetching latest commit…
Cannot retrieve the latest commit at this time
</pre> crazy </foo2> ==== - The hyphen character makes the text following it into "silent script", or Ruby script that is evaluated, but not output. <b>It is not reccomended that you use this widely; almost all processing code and logic should be kept to the Controller, the Helper, or partials.</b> For example: - foo = "hello" - foo << " there" - foo << " you!" %p= foo is compiled to: <p> hello there you! </p> ===== Blocks Like XHTML tags, you don't need to explicity close your Ruby blocks in HAML. Rather, they're automatically closed based on tabs. A block begins whenever the indentation is increased after a silent script command, and ends when the indentation decreases (as long as it's not an +else+ clause or something similar). For example: - (42...47).each do |i| %p= i %p See, I can count! is compiled to: <p> 42 </p> <p> 43 </p> <p> 44 </p> <p> 45 </p> <p> 46 </p> Another example: %p - case 2 - when 1 = "1!" - when 2 = "2?" - when 3 = "3." is compiled to: <p> 2? </p> == Using Haml as a Rails plugin Write Rails templates with the .haml extension. Example: # file: app/views/movies/teen_wolf.haml %html %head %title= "Teen Wolf (1985)" %body #contents %h1 "A highschooler discovers that he is a werewolf" %ul.cast %li "Scott Howard" %li "Rupert 'Stiles' Stilinski" %li "Lisa 'Boof' Marconi" %li "Lewis" is compiled to: <html> <head> <title>Teen Wolf (1985)</title> </head> <body> <div id='contents'> <h1>A highschooler discovers that he is a werewolf</h1> <ul class='cast'> <li>Scott Howard</li> <li>Rupert 'Stiles' Stilinski</li> <li>Lisa 'Boof' Marconi</li> <li>Lewis</li> </ul> </div> </body> </html> You can access instance variables in Haml templates the same way you do in ERb templates. Helper methods are also available in Haml templates. Example: # file: app/controllers/movies_controller.rb class MoviesController < ApplicationController def index @title = "Teen Wolf" end end # file: app/views/movies/index.haml #content .title %h1= @title = link_to 'Home', home_url may be compiled to: <div id='content'> <div class='title'> <h1>Teen Wolf</h1> <a href='/'>Home</a> </div> </div> --- Copyright (c) 2006 Hampton Catlin Licensed under the MIT License