looping in HTL sly in AEM | Community
Skip to main content
Level 2
May 23, 2021 7:30 AM UTC
Solved

looping in HTL sly in AEM

Hi,

 

I need to loop according to given Integer input.

 

Eg - According to user input, i need to repeat to print some HTML elements.

 

if user input is 1,

<div> 1 <div>

 

if user input is 2

<div> 1 <div>

<div> 2 <div>

 

How can i achieve this from HTL.

 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
May 24, 2021 12:29 PM UTC

HTL does not support traditional looping, arithmetic operations. 

you have to create a list from user input inside the sling Model as suggested by 

and then you can use data-sly-repeat
 
Arun Patidar

3 replies

arunpatidar
arunpatidarAccepted solution
New Participant
May 24, 2021 12:29 PM UTC

HTL does not support traditional looping, arithmetic operations. 

you have to create a list from user input inside the sling Model as suggested by 

and then you can use data-sly-repeat
 
Translate
Arun Patidar
Level 2
May 23, 2021 1:38 PM UTC

You can use sly-list or sly-repeat base on requirement.

Translate
ibishika
Level 4
May 23, 2021 9:56 AM UTC

Create an Integer List in the Sling Model based on the user input value. Fetch the list in HTL and loop over it.

Translate