| CARVIEW |
“All of Hashrocket’s new projects are done in Haml, and we’ve now decided to transition everything else in our portfolio over to Haml as soon as possible. The indentation-based approach works wonders for generating clean, semantic markup and the way that you can see the structure of your markup in a way that easily maps to CSS rules is simply brilliant.” - ‘Are you using Haml?’ - Obie Fernandez
“It’s so easy! Anyone can do it. Haml is sweeping the rails world like a wildfire of chicken, and everyone wants the biggest piece. I decided to try it last night on my new wallpaper site, and found that it’s extremely awesome to work with.” - ‘Cheating on ERB with Haml’ - Erik Gregg, Schadenfreude
“Any sufficiently complicated rhtml partial contains an ad hoc, informally-specified, bug-ridden, implementation of half of Haml.” - ‘Grigsby’s First Rule’, Dan Grigsby, Rail Spikes
What is it?
Haml takes your gross, ugly templates and replaces them with veritable Haiku.
Haml is the next step in generating views in your Rails application. Haml is a refreshing take that is meant to free us from the shitty templating languages we have gotten used to.
Haml is based on one primary principle. Markup should be beautiful.
However, its not beauty for beauty’s sake. Unspace Interactive and several other professional Rails shops use Haml exclusively for every one of their projects. In fact, it was created for use in highly productive environments. The beauty makes you faster.
Haml is a real solution to a real problem. Stop using the slow, repetitive, and annoying templates that you don’t even know how much you hate yet. Try something new — make templates fun and beautiful again!
If you sit down and try using Haml, you will learn it within 20 minutes.
Give yourself 5 minutes to read the Tutorial and then go convert one of your ERB templates to Haml. Feel the power of the Delete key. Simplify. Enjoy. Laugh. 20 minutes later, you will never go back.
The Showdown
Haml
#profile
.left.column
#date= print_date
#address= current_user.address
.right.column
#email= current_user.email
#bio= current_user.bio
ERB
<div id="profile">
<div class="left column">
<div id="date"><%= print_date %></div>
<div id="address"><%= current_user.address %></div>
</div>
<div class="right column">
<div id="email"><%= current_user.email %></div>
<div id="bio"><%= current_user.bio %></div>
</div>
</div>
Haml © 2006-2010 Hampton Catlin, Nathan Weizenbaum, Chris Eppstein, and numerous contributors. It is available for use and modification under the MIT license.