I created a custom component in AEM using the multifield functionality. However, it automatically places the values in a long string with commas in between.
I have gotten the values in an array using a custom JS file, but still can't figure out how to separate them or list them out.
I'm not sure if I can accomplish this inside the loop in my JS file or in the HTL file that is referencing the JS by using data-sly-repeat or data-sly-list
I would like each value to be a separate link tag with the value from the input as the href.
here's the js file:
"use strict";
use(function() {
var csspath = properties["csspath"];
var links = "";
for(var i = 0; i < csspath.length; i++) {
links += csspath[i]
}
return {
linkarray: links
};
});
and the html that references it:
<sly data-sly-use.csslinks="csslinks.js" />
${csslinks.linkarray}
right now the html prints out simply
test1test2
but I want it to appear as
<link href="test1.css" />
<link href="test2.css" />
without the user having to actually input <link href=.... />
I have tried adding html syntax in the JS file like so...
for(var i = 0; i < csspath.length; i++) {
links += '<link href="' + csspath[i] + '.css" />'
}
and even just
for(var i = 0; i < csspath.length; i++) {
links += csspath[i] + "<br />"
}
but it gives errors every time