How to apply a loop within a tag?

108 Views Asked by At

I have this such a list:

//properties.datas

data-hello="sup"
data-world="w00rld"

Can I generate a tag and loop all the data attributes into there? I only understand how to generate multiple HTML tags.

Result:

<div data-hello="sup" data-world="w00rld">
1

There are 1 best solutions below

0
On

You can pass a map to data-sly-attribute and it will render all corresponding pairs as attributes: key="value". See https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#223-attribute

<div data-sly-attribute="${model.datas}">...</div>