Hi
I have the Sling model in that i have list like below
public List<customList> getCustomProducts() {
return customProducts;
}
When i tried to identify the last item of list like below
<sly data-sly-list.product="${productModel.customProducts}">
<a href="${product.link}"><strong> ${product.name}</strong> </a>
<sly data-sly-test="${!product.last}">
<span class="separator">|</span>
</sly>
</sly>
in above code <span class="separator">|</span> is printing for last item as well
if list contains 3 items the | should print 2 times like below
product1 | product2 | product 3
But its printing like
product1 | product2 | product 3 |
can some help me how to identify the last item from list so that or how i can achieve this
Solved! Go to Solution.
Can you please try below and see if this works.
<sly data-sly-test="${!productList.last}">
<span class="separator">|</span>
</sly>
Can you please try below and see if this works.
<sly data-sly-test="${!productList.last}">
<span class="separator">|</span>
</sly>
Hello @manikanthar1295 ,
You need to use List keyword after the object(product) name. then it will be productList. https://www.aemtutorial.info/p/htl-sly-list.html
BTW you can also use the following properties if you need.
Hi @manikanthar1295 ,
You can use last property as below.
<ul data-sly-list="${currentPage.listChildren}">
<li data-sly-test="${itemList.last}">${item.title}</li>
</ul>
Please check below for more details in HTL.
https://www.aemtutorial.info/p/htl-home.html
https://www.aemtutorial.info/p/htl-sly-list.html
Regards,
Shiv
Views
Likes
Replies
Views
Likes
Replies