All <arrowheads> are gone
Tags and code both self-close by indentation
id=”xyz” and class=”abc” are just #xyz and .abc
<div> is the default tag - for others, use %tag
<%= some code %> is now just = some code
Same for <% some code -%>, use - some code
The RHTML version has 261 lexical tokens
counting each word in strings and syntactic white-space
The HAML version has 117 tokens
That makes it easier on the eyes and the ﬁngers!
Need care to close tags correctly in RHTML
In HAML, generated code is indented properly
including after nesting layouts and partials!
valid XHTML with no extra effort
DIVs almost always get a class or an ID or both
Plays well with RHTML during conversion
Attribute values are Ruby code:
Ruby blocks are automatically closed:
- @people.each do |person|
You can declare multiple classes, etc:
Other niceties... 2
ID and class attributes can come from an object:
uses @mother.class and @mother.id to become:
<div class=”person” id=”person_5724”>
Most self-closing tags are recognised
others may be declared self-closed: %br/
Comments start with a single / and are output!
Even multi-line; a comment wraps indented content
Other niceties... 3
Automatic generation of DOCTYPE tags:
!!! and !!! XML become
<?xml version=quot;1.0quot; encoding=quot;utf-8quot; ?>
<!DOCTYPE html PUBLIC quot;-//W3C//DTD XHTML 1.0 Transitional//ENquot;
Continue a long line using a trailing |
:ﬁlter passes the content to the ﬁlter:
Syntax highlighting modules available
JEdit, Eclipse + RadRails, TextMate, (G)Vim, Komodo, Emacs
or simple VIM setup (in your ~/.vimrc):
au BufRead,BufNewFile *.haml set sw=2 sts=2 et
How to install
Also available as a GEM for use outside Rails
See also SASS - similar approach for stylesheets
Developer discussion: http://groups.google.com/group/haml
Thanks to Hampton Catlin and his contributors!
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.