是否有一种方法可以将rails配置为默认使用haml,即当生成脚手架时,会生成相应的scaffold_name/index.html.haml
而不是scaffold_name/index.html.erb
.
类似于将config.sass.preferred_syntax = :sass
添加到config/application.rb
,并在默认情况下生成scaffold_name.sass
.
try 将以下内容添加到config/application.rb
config.generators do |g|
g.template_engine :haml
end
但我发现了以下几点
$ rails generate scaffold foo name:string
invoke active_record
create db/migrate/20120208152550_create_foos.rb
create app/models/foo.rb
invoke test_unit
create test/unit/foo_test.rb
create test/fixtures/foos.yml
route resources :foos
invoke scaffold_controller
create app/controllers/foos_controller.rb
error haml [not found]
invoke test_unit
create test/functional/foos_controller_test.rb
invoke helper
create app/helpers/foos_helper.rb
invoke test_unit
create test/unit/helpers/foos_helper_test.rb
invoke assets
invoke coffee
create app/assets/javascripts/foos.js.coffee
invoke sass
create app/assets/stylesheets/foos.css.sass
invoke sass
identical app/assets/stylesheets/scaffolds.css.sass
$ rails destroy scaffold foo
invoke active_record
remove db/migrate/20120208152550_create_foos.rb
remove app/models/foo.rb
invoke test_unit
remove test/unit/foo_test.rb
remove test/fixtures/foos.yml
route resources :foos
invoke scaffold_controller
remove app/controllers/foos_controller.rb
error haml [not found]
invoke test_unit
remove test/functional/foos_controller_test.rb
invoke helper
remove app/helpers/foos_helper.rb
invoke test_unit
remove test/unit/helpers/foos_helper_test.rb
invoke assets
invoke coffee
remove app/assets/javascripts/foos.js.coffee
invoke sass
remove app/assets/stylesheets/foos.css.sass
invoke sass
我创建了一个很好的小bundle命令,在this个屏幕播放之后用haml文件替换所有erb,但我仍然对在创建脚手架时将其设置为默认值感兴趣!我怎样才能让它成为haml文件(而不是erb!)是默认生成的吗?