开发者

How to generate Haml views instead of erb

开发者 https://www.devze.com 2022-12-18 10:54 出处:网络
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:

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 gen开发者_StackOverflowerated 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?


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


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 :)


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消