rails erbをhamlへ変換
railsアプリのテンプレートを、erbでなくhamlで作成しようと思ったので、erbからhamlへの変換手順をまとめてみました。
Gemfileに、次のgemを追加
gaml-rails・・・hamlを使うためのgem
erb2haml・・・erbをhamlに変換するgem
Gemfile
gem 'haml-rails'
gem 'erb2haml'
ターミナル
bundle install
ターミナル
rake haml:replace_erbs
を実行すると
hamlへ変換して、erbを削除してくれる。
ターミナル
Looking for ERB files to convert to Haml...
Converting: app/views/layouts/application.html.erb... Done!
Removing: app/views/layouts/application.html.erb... Removed!
Converting: app/views/layouts/mailer.html.erb... Done!
Removing: app/views/layouts/mailer.html.erb... Removed!
Converting: app/views/layouts/mailer.text.erb... Done!
Removing: app/views/layouts/mailer.text.erb... Removed!
きちんと、hamlへ変換されている。
Author And Source
この問題について(rails erbをhamlへ変換), 我々は、より多くの情報をここで見つけました https://qiita.com/tsuchinoko_run/items/0503fb87c0cb51bcecc7著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .