Haml v4.0.0 Release Notes

    • The Haml executable now accepts an --autoclose option. You can now specify a list of tags that should be autoclosed

    • πŸ’Ž The :ruby filter no longer redirects $stdout to the Haml document, as this is not thread safe. Instead it provides a haml_io local variable, which is an IO object that writes to the document.

    • 0️⃣ HTML5 is now the default output format rather than XHTML. This was already the default on Rails 3+, so many users will notice no difference.

    • πŸ’… The :sass filter now wraps its output in a style tag, as do the new :less and :scss filters. The :coffee filter wraps its output in a script tag.

    • πŸ’Ž Haml now supports only Rails 3 and above, and Ruby 1.8.7 and above. If you still need support for Rails 2 and Ruby 1.8.6, please use Haml 3.1.x which will continue to be maintained for bug fixes.

    • The :javascript and :css filters no longer add CDATA tags when the format is html4 or html5. This can be overridden by setting the cdata option to true. CDATA tags are always added when the format is xhtml.

    • HTML2Haml has been extracted to a separate gem, creatively named "html2haml".

    • πŸš… The :erb filter now uses Rails's safe output buffer to provide XSS safety.

    • πŸ”¨ Haml's internals have been refactored to move the parser, compiler and options handling into independent classes, rather than including them all in the Engine module. You can also specify your own custom Haml parser or compiler class in Haml::Options in order to extend or modify Haml reasonably easily.

    • Add an {file:REFERENCE.md#hyphenate_data_attrs-option :hyphenate_data_attrs option} that converts underscores to hyphens in your HTML5 data keys. This is a language change from 3.1 and is enabled by default. (thanks to Andrew Smith)

    • All Hash attribute values are now treated as HTML5 data, regardless of key. Previously only the "data" key was treated this way. Allowing arbitrary keys means you can now easily use this feature for Aria attributes, among other uses. (thanks to Elvin Efendi)

    • βž• Added remove_whitespace option to always remove all whitespace around Haml tags. (thanks to Tim van der Horst)

    • Haml now flattens deeply nested data attribute hashes. For example:

    .foo{:data => {:a => "b", :c => {:d => "e", :f => "g"}}}

    would render to:

    <div class='foo' data-a='b' data-c-d='e' data-c-f='g'></div>

    (thanks to PΓ©ter PΓ‘l Koszta)

    • Filters that rely on third-party template engines are now implemented using Tilt. Several new filters have been added, namely SCSS (:scss), LessCSS, (:less), and Coffeescript (:coffee/:coffeescript).

    Though the list of "official" filters is kept intentionally small, Haml comes with a helper method that makes adding support for other Tilt-based template engines trivial.

    As of 4.0, Haml will also ship with a "haml-contrib" gem that includes useful but less-frequently used filters and helpers. This includes several additional filters such as Nokogiri, Yajl, Markaby, and others.

    • Generate object references based on #to_key if it exists in preference to #id.

    • 🐎 Performance improvements. (thanks to Chris Heald)

    • Helper list_of takes an extra argument that is rendered into list item attributes. (thanks Iain Barnett)

    • πŸ›  Fix parser to allow lines ending with some_method? to be a Ruby multinline. (thanks to Brad Ediger)

    • Always use :xhtml format when the mime_type of the rendered template is 'text/xml'. (thanks to Stephen Bannasch)

    • html2haml now includes an --html-attributes option. (thanks Stefan Natchev)

    • πŸ›  Fix for inner whitespace removal in loops. (thanks Richard Michael)

    • πŸ‘‰ Use numeric character references rather than HTML entities when escaping double quotes and apostrophes in attributes. This works around some bugs in Internet Explorer earlier than version 9. (thanks Doug Mayer)

    • πŸ›  Fix multiline silent comments: Haml previously did not allow free indentation inside multline silent comments.

    • πŸ›  Fix ordering bug with partial layouts on Rails. (thanks Sam Pohlenz)

    • βž• Add command-line option to suppress script evaluation.

    • πŸš… It's now possible to use Rails's asset helpers inside the Sass and SCSS filters. Note that to do so, you must make sure sass-rails is loaded in production, usually by moving it out of the assets gem group.

    • The Haml project now uses semantic versioning.