You can do this with Node.JS...
npm install dustjs-linkedin
- (personally use the LinkedIn fork of dust)
var http = require('http');
var dust = require('dustjs-linkedin');
http.createServer(function (req, res) {
var compiled = dust.compile('<h1>Hello {name}</h1>', 'mytemplate');
res.end(compiled);
}).listen(80);
Obviously this is just an example, in a real script you would probably use some other mechanism, maybe Express. You would also use the 'fs' module to load the template from file.
On the client side request the compiled script from the server, your template will automatically be registered, so you can just do:
dust.render('mytemplate', {name : 'World'}, function(err, str){
...
});