Variable / String Interpolation?

Hi there I wanna display an HTML element given a condition… the only available options I have is use the actual condition with dmx-show

Now my question is, is there a way to interpolate strings or do class binding like e.g. <i class="fa fa-{{gender == 2 ? 'male' : 'female'}}"></i>

the only possibility is to do this and I don’t like it:

<i class="fa fa-female" dmx-show="gender == 3"></i>
<i class="fa fa-male" dmx-show="gender == 2"></i>
<i class="fa fa-user" dmx-show="gender == 4"></i>

It looks horrible on my source code and I’m a fellow servant of the DRY principle.

1 Like

you can use Class Toggle

<i class="fa" dmx-class:fa-female="gender == 3" dmx-class:fa-male="gender == 2" dmx-class:fa-user="gender == 4"></i>

1 Like

Ha!! called out! Thank you so much… I will definitely have to dig down the docs! :rofl:

1 Like