Home > DeveloperSection > Forums > Haml: how do I set a dynamic class value?
Goti Bandu

Total Post:119

Points:835
Posted on    December-28-2014 11:44 PM

 Ruby on Rails Ruby on Rails  CSS 
Ratings:


 1 Reply(s)
 631  View(s)
Rate this:
I have the following html.erb code that I'm looking to move to Haml:

<span class="<%= item.dashboardstatus.cssclass %>" ><%= item.dashboardstatus.status %></span>
What it does is associate the CSS class of the currently assigned status to the span.

How is this done in Haml? I'm sure I'm missing something really simple.

SOLVED: I can't believe I didn't figure that out on my own. Just goes to show that two sets of eyes are better than one. Thanks!


john rob

Total Post:108

Points:756
Posted on    December-29-2014 12:00 AM

 Maybe:

%span{:class => item.dashboardstatus.cssclass }= item.dashboardstatus.status

Don't want to miss updates? Please click the below button!

Follow MindStick