That's why my team made the lit-html library, which uses JS tagged template literals to make <template> elements for you, clone them and interpolate data where the JS expressions are, and then update the result really, really fast with new data:
import {render, html} from 'https://unpkg.com/lit?module';
let count = 0;
function increment() {
count++;
renderCount();
}
function renderCount() {
render(html`
<p>The count is ${count}</p>
<button @click=${increment}>Increment</button>
`, document.body);
}
renderCount();
You can try that out here: https://lit.dev/playground/#gist=1eff9baed1251fc60dd7da8b7f9...We're also working with Apple on a proposal called Template Instantiation which brings interpolations and updates into HTML itself (though the pandemic and things really stalled that work for the moment).