# Haml Changelog * Table of contents {:toc} ## 3.0.0.beta.1 [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.beta.1). ### `haml_tag` and `haml_concat` Improvements #### `haml_tag` with CSS Selectors The {Haml::Helpers#haml_tag haml\_tag} helper can now take a string using the same class/id shorthand as in standard Haml code. Manually-specified class and id attributes are merged, again as in standard Haml code. For example: haml_tag('#foo') #=>
haml_tag('.bar) #=> haml_tag('span#foo.bar') #=> haml_tag('span#foo.bar', :class => 'abc') #=> haml_tag('span#foo.bar', :id => 'abc') #=> Cheers, [S. Burkhard](http://github.com/hasclass/). #### `haml_tag` with Multiple Lines of Content The {Haml::Helpers#haml_tag haml\_tag} helper also does a better job of formatting tags with multiple lines of content. If a tag has multiple levels of content, that content is indented beneath the tag. For example: haml_tag(:p, "foo\nbar") #=> ## foo # bar #
#### `haml_tag` with Multiple Lines of Content Similarly, the {Haml::Helpers#haml_concat haml\_concat} helper will properly indent multiple lines of content. For example: haml_tag(:p) {haml_concat "foo\nbar"} #=> ## foo # bar #
#### `haml_tag` and `haml_concat` with `:ugly` When the {file:HAML_REFERENCE.md#ugly-option `:ugly` option} is enabled, {Haml::Helpers#haml_tag haml\_tag} and {Haml::Helpers#haml_concat haml\_concat} won't do any indentation of their arguments. ### Basic Tag Improvements * It's now possible to customize the name used for {file:HAML_REFERENCE.md#object_reference_ object reference} for a given object by implementing the `haml_object_ref` method on that object. This method should return a string that will be used in place of the class name of the object in the generated class and id. * All attribute values may be non-String types. Their `#to_s` method will be called to convert them to strings. Previously, this only worked for attributes other than `class`. ### `:class` and `:id` Attributes Accept Ruby Arrays In an attribute hash, the `:class` attribute now accepts an Array whose elements will be converted to strings and joined with `" "`. Likewise, the `:id` attribute now accepts an Array whose elements will be converted to strings and joined with `"_"`. The array will first be flattened and any elements that do not test as true will be stripped out. For example: .column{:class => [@item.type, @item == @sortcol && [:sort, @sortdir]] } could render as any of: class="column numeric sort ascending" class="column numeric" class="column sort descending" class="column" depending on whether `@item.type` is `"numeric"` or `nil`, whether `@item == @sortcol`, and whether `@sortdir` is `"ascending"` or `"descending"`. A single value can still be specified. If that value evaluates to false it is ignored; otherwise it gets converted to a string. For example: .item{:class => @item.is_empty? && "empty"} could render as either of: class="item" class="item empty" Thanks to [Ronen Barzel](http://www.ronenbarzel.org/). ### HTML5 Custom Data Attributes Creating an attribute named `:data` with a Hash value will generate [HTML5 custom data attributes](http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#embedding-custom-non-visible-data). For example: %div{:data => {:author_id => 123, :post_id => 234}} Will compile to: Thanks to [John Reilly](http://twitter.com/johnreilly). ### More Powerful `:autoclose` Option The {file:HAML_REFERENCE.md#attributes_option `:attributes`} option can now take regular expressions that specify which tags to make self-closing. ### `--double-quote-attributes` Option The Haml executable now has a `--double-quote-attributes` option (short form: `-q`) that causes attributes to use a double-quote mark rather than single-quote. ### `:css` Filter Haml now supports a {file:HAML_REFERENCE.md#css-filter `:css` filter} that surrounds the filtered text with `