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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

looping in HTL sly in AEM

Nesan
Level 2
Level 2

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

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

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
 

View solution in original post

3 Replies
ibishika
Level 4
Level 4

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

Sanket_Dange
Level 2
Level 2

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

Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

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
 

View solution in original post