Last Updated: February 25, 2016
· elia

Plain HTML attributes in Haml

When writing some Haml tag with HTML attributes the usual way looks like this:

%meta{:content => "authenticity_token", :name => "csrf-param"}

but recent Haml releases introduced a much better syntax:

%meta(content="authenticity_token" name="csrf-param")

This way you can avoid the full-blown hash syntax when writing only a couple of static attributes (plays well with HTML copy/paste too!).