HAML is a new template language for Ruby on Rails developed by Hampton Catlin, a Canadian Rails developer. It's a high-level, heavily semantic language that breaks the mold of RHTML and makes it very hard to make markup errors. In a way similar to Python, HAML relies on indentation, which it uses to enforce DOM hierarchy.
Here's an example of some HAML code in action:
!!!
%html
%head
%title Client Admin Site
%meta{"http-equiv"=>"Content-Type",
:content=>"text/html; charset=utf-8"}/
= stylesheet_link_tag 'tabbed'
= javascript_include_tag 'tabbed'
%body
#application
#header
.container
.statusbar
.logo
%strong Admin Interface
.menu= link_to 'logout',
:controller => 'account', :action => 'logout'
%br{:style=>"clear:both;"}/
.tabs
%ul.navigation
%li= link_to 'Member Approval', member_admin_url
%li= link_to 'User Management', user_admin_url,
:class => 'selected'
%li= link_to 'Pages', page_admin_url
%li= link_to 'Reports', reports_url
%li= link_to 'Help', '/'
#page
#content
//These will only render if there is
a non-false value returned from the helper
#errors= print_flash(:error)
#notice= print_flash(:notice)
= @content_for_layout
#sidebar= @content_for_sidebar || false
%hr/
#footer
%p= "Copyright Hampton Catlin 2006"Learn more in this article.

Comments
ncalpunker ·
Yuk! Yet another templating engine...when will people learn, lol.
Chadwick ·
This hurts my head. I have a hard time seeing what advantages this has of any other template engine.
I'm still waiting for someone (myself?) to implement a TAL (http://www.zope.org/Wikis/DevSite/Projects/ZPT/TAL%20Specification%201.4) engine. If you're going to use a template engine, it might as well be nice valid XML.
Ezra ·
Actually, I think nice in its own way. The only real showstopper is that it does not handle multi line ruby statements. So you can't write the normal @foo.each multi line iteration. Not sure why they decided to do that but its fairly limiting unless I am missing something here.
Jason ·
I quite like this from the standpoint that I hate HTML and XHTML, but I think this will be hard for people to adopt only because it is yet another thing for someone to learn and there will be fewer examples. I'm not saying this is good, just the way it probably will be.
Aaron Blohowiak ·
I don't like this.
Markaby http://markaby.rubyforge.org/ does this better, if you must.
rubylicio.us ·
Quite nice actually, I like how he got it simular to actuall CSS with "#" for uniqe ids, "." for classes and well, I guess % is ok for normal tags :). As ezra is pointing out it wouldn't be bad still having the possibilities.. or maybe it's there, I see some link_to's in there after ='s..
Rimantas ·
Oh, no... Looks like HARM to me...
Jeroen ·
I wonder how this performs! I can't imagine that it's quicker than the current template engine. Does anybody know this?
evan ·
I don't see much benefit to this over Markaby. With Markaby, your markup must validate as valid Ruby code, blocks and all, because it is real Ruby code. This means anything in Ruby is supported, you can't misnest anything, errors are caught early, and you don't have to learn any new syntax (ok, 30 seconds of new syntax: [ tag.idname!.classname ] == [ tag :id => 'idname', :class => 'classname' ]== [ ] ).
evan ·
WordPress swallowed my html tag example; sigh...
Peter Cooper ·
One thing I do like about it (whether for good or bad reasons) is the way you don't need to remember to close off a block.. but then I hit into one reason why I hate Python.
Sarah ·
Ugh, why try to turn any aspect of Ruby into Python? Awful, disgusting whitespace requirements...
David Marko ·
Would be great if someone could implement PageTemplates that Python has. Its great way how to embed code into tags and let designer goes his way.
ncalpunker ·
I agree with Chadwick about TAL. It has its good and bad, but if you are working with a designer and want to do round-trip design with something like dreamweaver, it is the best solution I have seen to date.
John Philip Green ·
More discussion can be found on the RoR-talk list: http://groups.google.com/group/rubyonrails-talk/browse_frm/thread/52a625a3f379f73a/e61fa29c4a48ef67?