Skip to main content
Level 3
April 17, 2022
Répondu

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!

Ce sujet a été fermé aux réponses.
Meilleure réponse par B_Sravan

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 commentaires

B_Sravan
Community Advisor
B_SravanCommunity AdvisorRéponse
Community Advisor
April 17, 2022

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. 

YuShengAuteur
Level 3
April 18, 2022

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