LoginSignup
132
138

More than 5 years have passed since last update.

Rails の ERB を Haml に変換する

Posted at

Haml に移行する際に、元々存在した app/views/layouts/application.html.erb はどうやって Haml にすればよいのか、悩んだので記録を付ける。

まずは、Gemfile に

gem 'erb2haml'

を追記し、

bundle install

を実行する。

rake -T

してみると、

rake haml:convert_erbs      # Perform bulk conversion of all html.erb files to Haml in views folder
rake haml:replace_erbs      # Perform bulk conversion of all html.erb files to Haml in views folder, then remove the converted html.erb files

が追加されていることがわかる。.erb を .haml に置き換えたかったので、replace_erbs を実行してみると、

$ rake haml:replace_erbs
Looking for ERB files to convert to Haml...
Converting: app/views/layouts/application.html.erb... Done!
Removing: app/views/layouts/application.html.erb... Removed!

となり、問題なく ERB から Haml に変換される。

132
138
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
132
138