a little place I like to call home.

Haml and Bootstrap

May. 1, 2013

In some of our projects at work we end up using display: inline-block to help with styling. There is a nasty side effect if you are using this with Haml on Rails. Haml on Rails will default to using ugly mode in production, but not ugly mode in development. Ugly mode will compress HTML to reduce spaces which messes up code that uses display: inline-block.

I typically run into this while using Bootstrap mini-buttons in a table:

inline-block with Haml Ugly mode on/off in development/production

In my eyes it is safer to enable ugly mode by default then risking an error in production.

Turn on ugly mode by putting this in your config/application.rb file:

Haml::Template.options[:ugly] = true

With Rails 4 I needed to put it in config/environments.rb to make it work.

comments powered by Disqus