tashig
Last Updated: February 25, 2016
·
3.367K
· tadas_t
Img 4302

Why you should start using Haml's ugly mode in development today

I have encountered a nasty quirk in a Rails project today, where two HTML elements would have a gap between them in development environment, but no gap in production. The problem seems to be HTML whitespace.

Haml has a so called 'ugly' rendering mode, which renders HTML with no indentation. Ugly rendering is on by default in production environments and off in development. The truth is, you don't really need nice HTML indentation in development mode: both Safari and Chrome Web inspectors will indent HTML for you automatically. Therefore the only thing you are likely to notice after turning ugly rendering on is faster HTML rendering speed!

So go ahead and put this in your environment.rb or config/initializers/haml.rb

Haml::Template.options[:ugly] = true
Say Thanks
Respond

1 Response
Add your response

6419
Cd857fed2b3d0f453861246f5f0dad1e

Thank you!

over 1 year ago ·