It is fairly easy to roll your own template solution. You just need to traverse the DOM and replaces string with a specific prefix and suffix, for instance {{ and }} with some other string.

Here is an example (make sure to show the developer console).


This implementation does not work in IE6/7/8 due to the the enhancement of NodeList and NamedNodeMap. It can easily be changed into for loops if support for IE6/7/8 is required.
NodeList.prototype.forEach = Array.prototype.forEach;
NamedNodeMap.prototype.forEach = Array.prototype.forEach;

Alternative solutions

There are many libraries that provides templates. Mustache is one of the best known.