Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
141
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

Rails の ERB を Haml に変換する

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 に変換される。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
141
Help us understand the problem. What are the problem?