Can $ rails generate scaffold give me .haml templates in stead of .erb ones?

2107 views
Skip to first unread message

Wojtek Galaj

unread,
Nov 15, 2010, 6:03:40 AM11/15/10
to Haml
Hello everyone.

I am really sorry if this question has been beaten to death. I tried
searching the group but could only find a discussion about maybe
implementing this from way back in 2007.

So, can I get .haml templates from rails 3.0.1 and not have to rename
and transcribe everything?

Thanks in advance,
Wojtek

Neil Funk

unread,
Nov 16, 2010, 9:07:31 AM11/16/10
to ha...@googlegroups.com
I don't know if there's another way to do this nowadays, but this
works well: http://haml-scaffold.rubyforge.org/

> --
> You received this message because you are subscribed to the Google Groups "Haml" group.
> To post to this group, send email to ha...@googlegroups.com.
> To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/haml?hl=en.
>
>

Dave South

unread,
Nov 16, 2010, 12:40:26 PM11/16/10
to Haml
Yes. There are several gems that handle HAML scaffold creation. I've
been using "haml-rails"

In my Gemfile:
gem 'haml-rails', :group => :development

The trick is to set HAML as the default generator in your
application.rb file:

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

Now rails generator will know to use HAML instead of ERB.

There are more options for config.generators.

http://railscasts.com/episodes/216-generators-in-rails-3
http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3

Dave
Reply all
Reply to author
Forward
0 new messages