Using HAML with Rails 3.2

Thoughts from the team
By    | February 8, 2012 | Development, Tools & Plugins, Uncategorized,

I’m currently working on a small internal project, so I’m taking the opportunity to try out HAML and see if I like it.

After some digging around I found various docs that suggested that you need to add the haml gem and include something like the following in application.rb

config.generators do |g|
  g.template_engine :haml

However, after a couple of attempts to generate HAML templates for a scaffold controller there was clearly something not quite right. I kept getting the following error:

error  haml [not found]

It turns out that the haml gem doesn’t give you generators for Rails 3.

After a bit more digging I found the haml-rails gem. Add that to your Gemfile and it adds generators for HAML, and enables it, so you can get rid of that declaration in application.rb

So now I’m all HAML’d up and ready to go. I like it so far, but we’ll see how I feel in a week or two of working with it.

More like this