LoginSignup
7
6

More than 3 years have passed since last update.

これは便利!1つのコマンドでHaml変換できる【Ruby on Rails】

Posted at

目次

  • gemを追記する(Hamlを導入する)
  • html.erbファイルを一括で変換する

gemを追記する(Hamlを導入する)

Gemfile
gem 'haml-rails'
gem 'erb2haml'

※(注意点)テスト環境と開発環境以外に追記する

ターミナル
$ bundle install

gemを記述したらこのプロセスを忘れてはいけませんでしたね!

html.erbファイルを一括で変換する

$ rake haml:replace_erbs

この処理が終わり、html.erbファイルが下記のようにHaml変換されていれば成功です。

!!!
%html
  %head
    %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
    %title ChatSpace
    = csrf_meta_tags
    = stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload'
    = javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
  %body
    = yield

END

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