Conditionally set CSS class

Pewh Gosh picture Pewh Gosh · Jan 22, 2012 · Viewed 8.6k times · Source

How to convert this ERB code:

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

into Haml code?

Answer

wvm2008 picture wvm2008 · Jun 6, 2012
%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