codepleb
codepleb

Reputation: 10571

How to apply a loop within a tag?

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">

Upvotes: 1

Views: 98

Answers (1)

Vlad
Vlad

Reputation: 10780

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>

Upvotes: 1

Related Questions