How to generate Haml views instead of erb

Daniel Kehoe picture Daniel Kehoe · Feb 1, 2010 · Viewed 17.9k times · Source

I'm building an app with Rails 2.3.4 and using

script/generate controller home index

to generate a controller and home page. I've got Haml installed. I get an erb file:

app/views/home/index.html.erb

but I'd prefer to have a Haml file generated instead, like:

app/views/home/index.html.haml

I recall Merb would generate .haml views instead of .erb if a haml gem was detected. Is this not available in Rails 2.3.4? I tried

script/generate controller home index --haml

but a "--haml" option is invalid.

Of course I can manually change my erb files to haml files but I'd rather have the generator do the work. Call me lazy. Suggestions?

Answer

Alex picture Alex · Nov 2, 2010

This gem will do the trick http://github.com/indirect/haml-rails