LoginSignup
26
27

More than 5 years have passed since last update.

Railsでerbをhamlに変換する方法

Posted at

簡単ではありますが、Railsでerbをhamlに変換する方法をまとめてみました。

3ステップで変換することが出来ます。

1.Gemfile の編集

Gemfileに

gem 'haml-rails'
gem 'erb2haml'

を追加する。

1つ目のGemで、hamlを導入。
2つ目のGemで、コマンド1つでhamlに変換できるためのGemである、erb2hamlの導入。

2.bundle install

bundle installを実行する。

3.変換してみる

ターミナルで、

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!
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!

となる。

これで、erbをhamlに変換することが出来ます。

26
27
0

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
26
27