Reputation: 1069
I have 10 items in list. I want to print only first 5 items in the list. How to add condition using data-sly-list
Upvotes: 0
Views: 3433
Reputation: 10780
You can use the index
or count
properties of the list item with data-sly-test
like:
<ul data-sly-list="${mylist}">
<li data-sly-test="${itemList.index < 5}">${itemList}</li>
</ul>
Alternatively, if your list is big and you do not want to iterate it, you could define an Use-API helper that creates a new list with just the first 5 needed elements.
Upvotes: 2