Is there a way to use plain old vanilla javascript (sans frameworks) to convert an html template string to an HTML element?
Here is what I have things I tried:
function renderBody(selector = body, template) { const prop.text = 'foobar'; const templateString = `<div id='test'>${prop.text}</div>` const test = document.createElement('div'); test.innerHTML = templateString; document.querySelector(selector).appendChild(test); }
This implementation works, but uses innerHTML and adds an extra wrapped div. Is there any way to do this without additional div ?
source share