DomTemplate Example

The save attribute is special. It takes the current node at sets it into the pointed to structure. In this case ${} is not arbitrary Javascript but a dot path to an element to set. This is useful whenever you need to work with the created nodes.

HTML

<script src="https://github.com/PAEz/domtemplate/raw/master/lib/domtemplate.js"></script>
    <div id="ex9">
      <div save="${element}">${name}</div>
    </div>

JavaScript

var data = {
    name: 'Fred'
};
template('ex9', data);
console.log(data.element.innerHTML); // "Fred"