My ternary statement isn't working properly in sightly

55 views Asked by At
<p> ${atcList.first || atcList.last} ? <b>Code ${atc.code}</b> : Code ${atc.code}</p>

I need that when the value is true, the result is bold, and when the value is false, another result is displayed, what is the error in my line? or, how it is working in sightly?

Now is : true ? Code 2 : Code 2

1

There are 1 answers

0
Vlad On

The ternary statement needs to be all inside the HTL/Sightly expression, you cannot mix it with HTML.

The HTL/Sightly way to do it is to use conditional data-sly-unwrap for the bold tag:

<p> <b data-sly-unwrap="${atcList.middle}">Code ${atc.code}</b> </p>