is there any way to iterate two list in sightly with below condition | Community
Skip to main content
Level 2
March 22, 2024
Question

is there any way to iterate two list in sightly with below condition

  • March 22, 2024
  • 1 reply
  • 665 views

<div data-sly-repeat.item="${items}">
 i=${itemList.count}

<div data-sly-list.value="${variableObject.iconImage}">

 j=${valueList.count}

<div data-sly-test.my=[${itemList.count}=${valueList.count}]>
<span class="cmp-accordion__icon nn-accordnion__icon__chevron">
<img src="${value.setImageIcon}" width="44" height="44" alt="${value.altText}">
</span>

</div>

</div>

 

.

is there any way to iterate like if(i==j) then only <span> image should come ? please help i have considered i and j in above code those are count of both list.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Level 4
March 25, 2024

Hi @shivamsh14,

 

I think the below code will work. I haven't tested it. But you can try it on your local.

<div data-sly-repeat.item="${items}"> <sly data-sly-list.value="${variableObject.iconImage}"> <sly data-sly-test.isMatch="${itemList.count == valueList.count}"> <span class="cmp-accordion__icon nn-accordnion__icon__chevron"> <img src="${value.setImageIcon}" width="44" height="44" alt="${value.altText}"> </span> </sly> </sly> </div>

 It is basically comparing the count of both list's count when both are equal then your span will be displayed.