My ternary statement isn't working properly in sightly

Viewed 17
<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 Answers

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>
Related