Walter Higgins is a believer in having a template language for you to use within JavaScript. He had issues with TrimPath's templating system, so he ended up creating SXOOP.template:
Writing TinyTemplate in Perl was a breeze and the codebase is tiny. I used a similar approach to writing SXOOP.template which resulted in a tiny codebase for the Javascript version too.
What need for Javascript Templating you ask ?
Well, JSON gives Javascript Templating something to do. More and more webservices are supporting JSON.
What’s more; if you combine SXOOP.template with this brilliant XML javascript library, then suddenly javascript templating becomes 1000 times more useful (most existing WebServices use XML). You can mix and combine XML data sources (like the ubiquitous RSS and less well known formats like OPML) and use them to construct Human-readable web-pages without resorting to XSLT.
Example template usage
This example snippet is taken from the poor mans blog template
<textarea id="bookmarks" style="display:none;">
<ol>
[:
for (var i = 0; i <$_["rdf:RDF"].item.length; i++) {
var bookmark = $_["rdf:RDF"].item[i];
:]
<li><h4><a href="[:= bookmark.link :]">[:= bookmark.title :]</a></h4>
<p>[:= bookmark.description :]</p>
[: } // end for loop :]
</ol>
</textarea>
The entire library is here at 82 lines of commented code.