こんにちは。Takitaです。
最近はhamlを使用するケースが多かったのですが、
久しぶりにslimを使ってみたので手順をメモしました。
slim-rails
と html2slim
を入れます。
html2slim
はerbからslimに変換するために使用するので、
developmentのみでOKです。
# Gemfile
+ gem 'slim-rails'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
+ gem 'html2slim'
end
viewを生成した時にerbからslimにデフォルトを変更するために
config/application.rbを書き換えます。
module SampleApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
+ config.generators.template_engine = :slim
html2slim
を利用してerbからslimに変換します。
$ bundle exec erb2slim -d app/views/*