Hellama - Cloning elements

Back to Hellama

There is also a special data-foreach attribute, which clones the childnodes of the container for each item in the config under the specified key (the value must be an array). Note the contents of data-foreach is not in the open and close sequence (usually curly brackets). The attribute is removed after the processing.

<ul id="test" data-foreach="items"> <li>{one}</li> <li>{two}</li> </ul> const cfg = { open: "{", close: "}" }; const data = [ {one: "eins", two: "zwei"}, {one: "raz", two: "dva"} ]; const tags = { items: data }; hellama([test], tags, cfg);