For data-sly-list and data-sly-repeat there should be a prepared object reference to the previous and next item in the list. It is not right to have a dedicated custom SlingModel function for that, as I see a lot of useless code in a lot of SlingModels to get previous or next elements. It is also no business logic having next item e.g. if you have list items that have a button to get e.g. the label to the next or previous item. As workaround for next I can use the count field, but that is a hack and this is not working for previous item.
<p data-sly-repeat="${myMap}">
<span>key: ${item}</span>
<span>value: ${myMap[item]}</span>
<button class="prev">Click here to go to previous item: ${item.prev.label}</button >
<button class="next">Click here to go to next item: ${item.next.label}</button >
</p>
Expected Behaviour
For data-sly-list and data-sly-repeat there should be a prepared object reference to the previous and next item in the list. It is not right to have a dedicated custom SlingModel function for that, as I see a lot of useless code in a lot of SlingModels to get previous or next elements. It is also no business logic having next item e.g. if you have list items that have a button to get e.g. the label to the next or previous item. As workaround for next I can use the count field, but that is a hack and this is not working for previous item.
Actual Behaviour
https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#226-list
Sample Code that illustrates the problem