Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Haml 1.7 Released: Now 16 Times Faster Than Markaby

By Peter Cooper / July 10, 2007

Hamlagain

Ruby Inside has mentioned Haml, a couple of times before. It's a template language for Rails developed by Hampton Catlin, and it acts as a high-level, highly semantic alternative to RHTML. It relies on indentation for structure (a la Python) and includes a CSS meta-language (Sass) to make it super easy to dynamically produce XHTML-compliant pages that are easy to tweak later on.

Hampton has just released Haml 1.7, a major revision that boosts Haml's speed to merely 30% less than that of raw Erb (which RHTML templates rely on), which, supposedly, makes it 16 times faster than Markaby, another alternative page generation library. Hampton also says that they're planning for Haml to be faster than standard Erb by Haml 2.0.

Check out the official Haml site, there's lots of examples, and it's really easy to get up and running with it. If you haven't considered an alternative to standard Rails templates before, now's a good time to check it out.

Comments

  1. Jerrett says:

    but still ugly :(

  2. Sean says:

    @Jerrett: Entirely a matter of opinion. Personally, I like it. It also reduces validation/correctness bugs by auto-closing tags based on indentation... a big plus for me.

  3. Luis Lavena says:

    Even so, I still prefer "Lilu":http://trac.railsware.com/lilu

    Still very alpha, but looks more promising and "designer frendly" than Markaby or Haml

  4. Jerrett's Mom says:

    Why must you always be so negative, dear?

  5. Dan says:

    @Luis: designers /love/ haml, because it uses shares so much syntax with CSS. Seen recently, "Loving haml, didn't think I would."

  6. Luis says:

    @Dan: didn't see that post in my RSS feeds, could you point me to the article?

    (I do my homework and didn't find it with google ;-)

    Anyway, when designer is not part of development team, or not a programmer, break the barrier and getting his hands dirty (or cleaner) with something new is often time you don't have, neither the team.

    I have often worked with designs coming from outside, already created. AFAIK there is no way to designers show a html mockup without playing with a programming framework, and they are used to dreamweaver :-P

  7. Jerrett says:

    I agree, it's a matter of opinion - I prefer Markaby's (which is Ruby) and it has all the same benefits you mentioned!

    Anyway, you are right - it's all preference. In my situation, we're doing a lot of html - and I prefer Ruby's (markaby) syntax anyday over css-esque (Haml), HTML (erubis,lilu). If you need a designer-friendly markup language, something like lilu is likely even better - plain, 100%, HTML.

    One thing that jumps out about haml that i don't like is that it encourages extremely div-heavy markup. If everything is a div, it's fairly clean, but that's not typically considered good markup. If you want good markup, your haml starts to look less-clean!

  8. RSL says:

    @ Jerrett: the div-bloat you write about Haml isn't because of Haml though but because some people don't understand that you can style other block-level elements [like ul, ol, p, ...] just as easily as you can a div. Haml just makes their bad habit more obvious.

  9. Chuck Vose says:

    @Jarrett: One of the greatest things about Ruby, a facet borrowed directly from LISP, is that we can write DSL's for whatever domain we happen to be working it. Haml/Sass is still pure ruby just like Markaby except that it requires less typing. Both are beautiful, both have incredible shortcomings. For us, Haml/Sass are a wonderful thing but you're right that when working with a design team it can be rigid. My bet is that any intelligent designer could figure out Haml in 20 minutes though. I fear for the team where the designer is so set in their ways that they couldn't.

Other Posts to Enjoy

Twitter Mentions