Pretty HTML Output With HAML

HAML, by default in development renders “pretty”, correctly indented HTML output. In production it renders “ugly” output by default. I really appreciate the value of indented html output. If only so that when debugging HTML source (sometime DOM isn’t good enough) you can see the hierarchy of the page. Many an hour has been spent searching for that elusive missing closing

.

I have however always had problems setting the HAML :ugly option in production…. until now.

https://groups.google.com/forum/?fromgroups=#!topic/haml/M90y2hSRZTE

It seems that due to changes in the way rails loads, you now have to create an initializer (obvious really) and add the option there.

Haml::Template.options[:ugly] = false
Advertisements

About distinctinteractive

I graduated 3 years ago from the University of Huddersfield with a 2:1 BA in Interactive Multimedia. After leaving University i worked for a small company in Huddersfield (Offroad Code) mainly helping to maintain a large travel company website. I am currently freelancing as Distinct Interactive. Follow me on Twitter @jimmckerchar
This entry was posted in Random Stuff and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s