Closed phmngocnghia closed 6 years ago
@PhmNgocNghia is using of ternary operator enough for you? Like:
a(className=foo === bar ? foo : bar)
It works currently, have you tried?
Yes, pug supports arbitrary js expressions for attribute values just like jsx does, so just use a ternary.
Can we have if else in attribute. like this :
a( className=if(foo===bar) foo else bar )
Transpile into :
<a href={foo===bar? 'foo' : 'bar'}
/>