Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haml - how to put ruby variable into the name of class identifier

This is a line, which I use for formatting my links:

%a.accordion-toggle.toggle-6{:href => "#"} #{name}

I would need to have an option to put in this class toggle-6 my own digit, for example toggle-1 etc.

How to do that in HAML syntax? I've tried something like

%a.accordion-toggle.toggle-#{id}{:href => "#collapseOne"} #{name}

But this returns

Illegal element: classes and ids must have values.
like image 302
user984621 Avatar asked Jul 18 '12 08:07

user984621


1 Answers

You can specify dynamic values as attributes:

%a{class: "accordion-toggle toggle-#{id}", href: "#collapseOne"} #{name}
like image 91
Hck Avatar answered Oct 19 '22 16:10

Hck