Pug mixin with computed CSS class name
My pug mixin tweet
normally just generates this HTML:
<div class='col-md-3'></div>
I pass tweet
the parameter index
, which is a zero-based positive number. When index
equals tweetData.index
(defined elsewhere) I want the generated div
to glow, like this:
<div class='blueGlow col-md-3'></div>
This is my attempt:
mixin tweet(index)
div.collapse(class= tweetData.index === index ? "blueGlow" : undefined).col-md-3(data-index=index)
The error message is: You should not have pug tags with multiple attributes.
div.collapse.col-md-3(class=(tweetData.index === index ? "blueGlow" : undefined), data-index=index)
– Lesko