
data-sly-list repeats the content of the host element for each enumerable property of the provided object.
<dl data-sly-list="${currentPage.listChildren}">
<dt>index: ${itemList.index}</dt>
<dd>value: ${item.title}</dd>
</dl>
Here item is the current item in the iteration, and itemList is the object holding the properties below.
itemList properties
| Property | Description |
|---|---|
index | zero-based counter (0..length-1) |
count | one-based counter (1..length) |
first | true if the current item is the first item |
middle | true if the current item is neither the first nor the last item |
last | true if the current item is the last item |
odd | true if index is odd |
even | true if index is even |
Accessing a list value dynamically
<dl data-sly-list.child="${myList}">
<dt>key: ${child}</dt>
<dd>value: ${myList[child]}</dd>
</dl>
To repeat the element itself rather than its content, use data-sly-repeat.