By Peter Cooper / September 14, 2006
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. Read More