35

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?

3 Answers 3

35

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

1
  • Good answer for Rails 3.0. And we should be using Rails now. Commented Nov 2, 2010 at 5:11
2

Waht actually worked for me, but in rails 3.1 is this wiki here: https://github.com/plataformatec/devise/wiki/How-To:-Create-Haml-and-Slim-Views :)

0

This gem here might be useful. I don't think there is any way to do this outside of a plugin/gem. (disclaimer: I haven't tried this myself, but came across it when I was researching the same thing)

Not the answer you're looking for? Browse other questions tagged or ask your own question.