Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditionally set CSS class [duplicate]

How to convert this ERB code:

<div <%= 'class="highlight"' if job.done %>>

into Haml code?

like image 885
Pewh Gosh Avatar asked Jan 22 '12 04:01

Pewh Gosh


1 Answers

%div{:class => ('hightlight' if job.done)}

I believe would also do the trick, and doesn't create class= '' if job.done == false, also looks more like your initial code

like image 150
wvm2008 Avatar answered Oct 18 '22 18:10

wvm2008