Is using HTL to remove last separator/comma possible? | Community
Skip to main content
Level 3
Apr 17, 2022 12:51 PM UTC
Solved

Is using HTL to remove last separator/comma possible?

Dear community,

 

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

 

 

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?

 

 

Thanks in advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
B_Sravan
B_SravanAccepted solution
New Participant
Apr 17, 2022 3:31 PM UTC

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. 

2 replies

B_Sravan
B_SravanAccepted solution
New Participant
Apr 17, 2022 3:31 PM UTC

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. 

Translate
YuShengAuthor
Level 3
Apr 18, 2022 2:36 AM UTC

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

Translate