[ACCEPTED]-Conditional class in HAML-haml
Accepted answer
Try this
%tr{ :class => ("overdue" if ap.overdue?) }
0
HAML has a nice built in way to handle this:
%tr{ class: [ap.overdue? && 'overdue'] }
The 4 way that this works is that the conditional 3 gets evaluated and if true, the string gets 2 included in the classes, if not it won't 1 be included.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.