Building list items in JavaScript with long strings of HTML gets messy and invites escaping bugs. A <template> keeps the markup in the HTML, where it belongs.
<template id="row">
<li class="item"><span class="name"></span></li>
</template>
<ul id="list"></ul>
The content of a template is not rendered. The browser parses it and keeps it aside in the content property, a DocumentFragment. Then copy it per item:
const template = document.getElementById("row");
for (const name of ["Sonarr", "Radarr"]) {
const clone = document.importNode(template.content, true);
clone.querySelector(".name").textContent = name;
document.getElementById("list").appendChild(clone);
}
importNode(..., true) makes a deep copy. MDN uses it in its example and prefers it over cloneNode(), because it creates the copy in the context of the current document, which matters for custom elements.
Setting textContent instead of building an HTML string also means a name with a < in it is shown as text, not run as markup.
Caveats. An event listener attached to the fragment itself is lost when you append it: MDN says to attach listeners to the child elements instead. The template’s own childNodes is always empty, so look in content, not in the template. MDN marks the element widely available since November 2015.
Further reading: MDN: the template element