Switching to HAML from ERB

I’ve recently switched from ERB to HAML and I have to admit it’s an absolute joy to use, not sure why I didn’t make the switch sooner.

I find the best way to learn a new framework or language is to put it through a short litmus test. For Haml I built a small CRUD app, after about 15 minutes I couldn’t see myself going back to erb.

I looked at an old rails project I did using erb, I suddenly had this urge to rewrite it using haml.

Haml makes a lot of sense to me, since switching to Ruby, I’ve wanted everything that I use to be less verbose (here’s looking at you Java!). In the same vain of though, I plan on switching to CoffeeScript for my Javascript development, I manage I will have similar of Haml as I will of CoffeeScript.

Haml comparison

Haml is based on the principle that markup should be beautiful. It accomplishes this by enforcing indentation ( I had to learn this the hard way), respects the DRY principle by removing the need of closing tags on elements.

The only pet peeve I have is how you declare a html5 doc by writing “!!! 5”, seems odd to me, perhaps there’s a logic reason to this that I’m not aware of.

There’s a few helpful haml tools out there, such as html2haml, haml-lint

A useful link about getting started with HAML http://railsapps.github.io/rails-haml.html
Ced

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s