What’s new in Haml 3.2 beta?

It’s been a while since I’ve posted anything, but a lot has been happening behind the scenes. First of all, my second son, Oliver, was born 5 weeks ago, so I’ve had a whole lot more than Haml on my mind lately!

Luckily for the project, though, Matt Wildig has come on as a core committer and been picking up my slack for the last few months. The upcoming 3.2 release includes tons of great work by him. We’re close to ready to release 3.2.0, but are going to do another beta or two, and then a few release candidates to make sure we catch as many bugs as possible.

So what’s new in Haml 3.2? I’m glad you asked. This will be an incremental release without any major language changes. Our overall goals for 3.2 have been to fix bugs, simplify the codebase, improve the default settings, and remove annoyances.

So with that said, here are some of the highlights coming your way in the next release:

Improved Filters

Filters are now based on Tilt, making it much easier to add new ones. If it works with Tilt, it works with Haml. As such, we’ve also added a few new filters for more popular things like LESS, Coffeescipt and The SCSS flavor of Sass.

The Sass and other CSS-oriented filters now automatically wrap your code in <style> tags too. That means if you rely on the :sass filter in any of your apps, you’ll have to adjust some of your code when updating to Haml 3.2.


We’ve made several changes to Haml’s defaults to make its output more in line with what people expect in 2012. HTML5 is now the default output format everywhere. It already was the default in Rails, but if you’re using Haml with Sinatra, Padrino or Ruby frameworks, this may affect you.

Haml also now uses dashes when building HTML5 data attributes from hashes - previously it used underscores, which many users found surprising and/or annoying.

Security Fixes

The Erb filter now uses the same XSS-safety features as the rest of Rails.


Haml now supports only Rails 3.0+ and Ruby 1.8.7+. This change allowed us to eliminate a significant amount of code. The Haml 3.1 branch will continue to be maintained for bug fixes for people running older Rails apps that can’t update to Haml 3.2.

The `html2haml` utility has been extracted to its own gem.

We’ve added a haml-contrib gem to have a place to put less-frequently used features, and moved the Textile and Maruku filters there.


Haml’s test suite now emits only one warning, down from several thousand that 3.1.5’s test suite emitted. Haml is also now tested green against JRuby and Rubinius on Travis.

We removed lots of dead code and refactored in a few places to make the code easier to understand and maintain. In particular, we split out the parser and compiler modules into separate classes; previously they had been mixed into an engine module and couldn’t be used on their own. Programmers looking to hack on Haml’s compiler and parser will have an easier time on 3.2.


Haml’s parser got some modest performance improvements and is now a little less than 10% faster than Haml 3.1’s. This has little effect on production applications, since in production templates are generally only parsed once and then cached. Still, every little bit helps. 

We also fixed a major performance issue when rendering lots of partials on JRuby.

Miscellaneous Things

We’ve added a few other minor features and configuration options, and fixed lots of small bugs. If you’d like to see all the details check out the changelog.

Summing up…

Haml 3.2 has more of what you love and less of what you hate. It will improve your life in numerous ways: you’ll be more attractive, more wealthy and become smarter if you use it. Well, not really, but we think there’s something in this release to make almost everybody just a little happier with Haml. Give it a try and send us your feedback!

An infrequently updated blog with news and information about the Haml template language.

Blog Archive

Haml Home

Source Code

Google Group