Adventures with Ruby

First Haml evaluation

View Comments

As I promised, here is the evaluation of redoing a site from ERB to Haml. To immediately cut to the chase: Haml IS worth it!

  1. It’s so definitely faster and easier to write than ERB.
  2. Your HTML output is nicer.
  3. Partials rendering with the right indentation automatically.
  4. It forces you to take a good look of what you’re actually making.
  5. Because it’s so strict on it’s syntax, you will be using more helpers and custom model methods, which is a good thing.
  6. No more forgetting to close a div and spending hours to find out which one.
  7. Faster refactoring because of less code and easier to read.

There are some downsides however. I’d rather not talk about the hours I tried to fix some idiot problem with partials and the locals option. Just use locals as less as possible, preferably not at all. Some cons:

  1. Yet another syntax to be learned.
  2. Errors with Haml syntax are a bit harder to locate, but you’ll make less after you encountered a few.
  3. A gem needs to be installed on the server, which can be difficult if you don’t have root rights on the server
  4. The syntax highlighter on VIm is not quite up to it.
  5. Rails helpers screw up the nice HTML Haml creates for you. The form_tag helpers for example.

So if you are starting a new project, or redoing the entire HTML of you’re application: try Haml! Chances are you’ll like it!

Sneak preview:

The old design: The old design and the new design: The new design

Written by Iain Hecker

February 15th, 2008 at 1:59 pm

Posted in Uncategorized

blog comments powered by Disqus