That's a bold claim, but it is pretty easy, pinky promise!
Every element that has an attribute that you want to be rendered, should also have an empty data-tpl attribute.
There are 6 possible data attributes
data-tpl-htmlsetsel.innerHTMLdata-tpl-textsetsel.innerTextdata-tpl-hrefsetsel.hrefdata-tpl-srcsetsel.srcdata-tpl-altsetsel.altdata-tpl-titlesetsel.title
<div id="my-template">
<span data-tpl data-tpl-text="data.something"></span>
</div>// Prepare the template
var template = new Template(document.getElementById('my-template'));
// Render it
var result = template.render({
something: 'This is some text'
});
// Add it to the document
document.appendChild(result);As the content of the data attribute is just JavaScript, you can also do more complex things.
<!-- Functions -->
<span data-tpl data-tpl-text="data.something.toUpperCase()"></span>
<!-- Simple if -->
<span data-tpl data-tpl-text="data.wants_something ? data.something : ''"></span>I've written a blog article about this, you can read it here. There are a few examples there.