Dug.js – A JSONP to HTML Script
rog.ie
rog.ie
Another way to implement smart templates is to use XSLT, which is both standardized as well as longtime proven. XSLT is used commonly used with XML but with DefiantJS, it's trivial to transform JSON structures with XSL (additionally, it's possible to search JSON structures with XPath queries using this lib; http://defiantjs.com/#xpath_evaluator).
XSLT is great for transforming XML datasets to other XML datasets. It's just not designed for outputting web pages.
NB I've used XSLT a lot over the years (not client side though) and I have a healthy respect for what is possible with it - but as I rather prefer JSON to XML these days it seems a bit like overkill.
What are the testing options like for XSLT, are you able to run good automated tests against your templates?
I created http://apidocjs.com and had the problem that i needed some "simple" logic in the templates (handlebars). For such things i must implement a separate view with configuration/data modelling/... and Helper function, but that makes the project-output complex, because i want that the people can change the template as easy as possible. Quick & dirty developed i create many duplicate code in the template to avoid a separate view. It was a silly idea, it makes the template more complex ;-) And only because of some missing logic.
Regarding Mustache and Handlebars; the basic idea is that templates should be logic-free - despite this, there are many question at Stackoverflow, on how to add intelligence when using these templating engines. The basic idea and real-life implementation doesn't add up...
<template id='mytemplate'>
my data is {{data}}
</template>
<script>
doit('mytemplate', 'http://api.dribbble.com/.../shots')
// or jq plugin
$('#mytemplate').render('http://...');
</script>