LoginSignup
19
17

More than 5 years have passed since last update.

slimで出力されるhtmlの設定を変える

Last updated at Posted at 2013-04-09

slim綺麗ですね。
ですがデフォルトのslimで出力されるhtmlは特に何も考えずに使うと一番効率の良い(読みにくい)htmlの体裁になります。
なので config/initializers/slim.rbというファイルでも用意して

config/initializers/slim.rb
Slim::Engine.set_default_options :pretty => true

と書くことでお行儀の良いhtmlを吐いてくれます。
productionの時はパフォーマンス重視だからもっとuglyなhtmlでいいよという要望もあると思います。
そういう人は

config/initializers/slim.rb
Slim::Engine.set_default_options :pretty => true unless Rails.env == 'production'

にしておけばproductionの時だけはuglyでぎっちりしたhtmlを吐いてくれます。便利。

19
17
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
19
17