Haml is a markup language for generating xml and other markup - most popularly HTML. Over the past few weeks I have been writing a few Ruby on Rails applications and chose Haml as the templating language. For someone who has traditionally avoided positional languages this was a strange choice. Having written a few simple applications I find that the writing HTML in Haml is both straightforward and intuitive. Good HTML is naturally hierarchical and having this structure both encouraged and enforced in Haml feels right.

Generating

#some-id.someclass

is one of the great things about haml

Produces

<div id='some-id' class='someclass'></div>

There are definitely some quirks. Sometimes I have to switch styles or div tags and in some cases declare them explicitly with a %div. These cases are generally when generating html in iterators and not a big deal. %script tags, in line with the rest of Haml, can’t have additional indentation - which encourages me to take this content and push it into included JavaScript files, something that I think is good practice anyway.

comments powered by Disqus