slim dynamic conditional class

Sergey Alekseev picture Sergey Alekseev · Mar 6, 2013 · Viewed 42.9k times · Source

Just to help other developers, because there is no similar question on SO.

div class=(is_active? ? 'active' : 'inactive')
div class=('active' if is_active?)

Answer

Sergey Alekseev picture Sergey Alekseev · Apr 10, 2013

See the examples below:

div class=(is_active? ? 'active' : 'inactive')
div class=('active' if is_active?)

The same approach can be used to assign dynamic values to other attributes.