Pat
Pat

Reputation: 163

Sightly how to test is a string contain another substring

in HTL/Sightly, how can I compare an item is in the array? or a string contain a sub string?

Like I have array1(apple, banana, orange), array2(apple,pear)

<div data-sly-list.item=${array1}>
<div data-sly-test=${array2 == item.name}>if match </div>
 all other code ...
</div>

so in the above example, only apple will have the extra div

Upvotes: 1

Views: 5116

Answers (1)

Vlad
Vlad

Reputation: 10780

Since version 1.4, you can use in relational operator: https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#1143-relational-operators

<div data-sly-test="${item in array2}">if match</div>

Upvotes: 2

Related Questions