'conditionally have css tag inline in slim

I have a set of css tags like this:

.card.hidden.small.u-margin-bottom-1

I'd like to conditionally show the .hidden tag while maintaining this style of syntax (I have seen this slim dynamic conditional class and don't want to change style).

Could I do something like?

.card(.hidden if true_statement).small.u-margin-bottom-1

but this doesn't seem to work.



Solution 1:[1]

You can do something like this:

.card.small.u-margin-bottom-1 class=(:hidden if true_statement)

for more classes:

.card.small.u-margin-bottom-1 class=('class-1 class-2' if true_statement)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 blackchestnut