HAML - parameter with dash

user984621 picture user984621 · Jul 16, 2012 · Viewed 10.5k times · Source

How can I convert this line

  <body data-spy="abcd">

to HAML syntax?

This one returns me an error

  %body{:data-spy => "abcd"}

Answer

CrazyVipa picture CrazyVipa · Jul 16, 2012

HAML Syntax for the HTML5 Data Field:

%div{ :data => {:id => '555'} }

Now, I started messing around, and it looks like this only works with "data" -- other tags need to be:

%div{ "star-datas" => "hello!" }

Your example:

%body{:data => { :spy => 'abcd'}}