Let's say I want to add 2 classes on a DOM element of my choosing based on a boolean variable I've got. With 1 class it would be really simple, just by doing:
<span class="{ class1 : variable }">Text</span>
But what about 2+ classes?
I attempted:
<span class="{ class1, class2 : variable }">Text</span>
<span class="{ ['class1', 'class2'] : variable }">Text</span>
<span class="{ class1 && class2 : variable }">Text</span>
Is there an actual way or it's impossible right now?
I just want to avoid having to do this:
<span class="{ class1: variable } { class2: variable }">Text</span>
Thanks.
That is possible, yes.
If
class1
andclass2
are actual CSS classes, this would work:If
class1
andclass2
are just variables holding CSS class names, I'd use something like this: