LoginSignup
2
2

More than 5 years have passed since last update.

erbをslimに変換したい

Last updated at Posted at 2015-10-29

Railsプロジェクトの途中でhtmlテンプレートをslimに変更したくなった。
viewはぜんぜん作り込んでなかったので、こんなgemを入れてサクッと変換してみた。

Gemfileに追記。

gem 'html2slim'

./vendor/bundle下にインストール。

$ bundle install

html2slimコマンドとerb2slimコマンドが使えるようになる。
こちらを参考にターミナルに下記を入力。
https://github.com/plataformatec/devise/wiki/How-To:-Create-Haml-and-Slim-Views
プロジェクト下にインストールしたので、bundle execをつける。

$ for file in app/views/**/*.erb; do bundle exec erb2slim $file ${file%erb}slim && rm $file; done

.slimに変換されている。
以上。

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