Why not just use ERb?
I have to laugh when I read the sometimes visceral reactions people have to Haml – people who ask rhetorically, "what's wrong with using Erb?" I'm not in the business of trying to solve problems you don't have. If you are fine using Erb, keep using it. You're not doing anything wrong, but you're missing out. You're using nano, when you could be using vim. You're using TextEdit when you could be using TextMate. You're using Notepad when you could be using, well, whatever the hell people use on Windows.
Your shrieks of agony when you view Haml for the first time sound like those emitted by the newbie who fires up vim, can't figure out how to type anything, and gives up after 1 minute. Like vim, Haml is optimized for the repeat user. It's not designed to be pleasing to your eye the first time you see it. Like vim, it sacrifices discoverability for usability.
Just as brevity is the soul of wit; lack of repitition is the soul of programming. Manually editing HTML/Erb means you're typing hundreds or thousands of repetitive "<", ">" and "%" characters over and over again that you don't need to if you use Haml. Because of its brevity, you can visually scan through a large view in Haml much more easily than one written in Erb. All of the repetitive crap that can be simply inferred from context is gone, leaving you only with elements that mean something: concise, simple control structures, your content, and the CSS ids and classes you want it associated with.
Striking the right balance between brevity and meaning is the whole point of Haml, and it does this much better than any template language I've worked with. If you took one look at Haml and ran the other way, I urge you to give it a chance for a few days on your next project. Chances are you will never go back.
Published