Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Is using HTL to remove last separator/comma possible?

Avatar

Level 2

Dear community,

 

I'm using multifield and a sling Model (for loop) to dynamically add content on my footer as below:

 

multi.pngfooter.png

 

I wonder if it's possible to remove last separator (which is written in my html file) with HTL?

Or this can only be done in the Sling Model?

 

HTL.png

 

Thanks in advance!

1 Accepted Solution

Avatar

Correct answer by
Level 5

yes, In brief: check for the last child in the list and don't display it.

<sly data-sly-test="${!itemList.last}"><span class="link-separator"></span></sly>, here I am displaying the separator only if the list item is not the last one. 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

yes, In brief: check for the last child in the list and don't display it.

<sly data-sly-test="${!itemList.last}"><span class="link-separator"></span></sly>, here I am displaying the separator only if the list item is not the last one. 

Avatar

Level 2

Thank you @BattiniSravan, it works and am getting more ideas about how to use data-sly-test 🙂