Skip to content

Instantly share code, notes, and snippets.

@seriousManual
Forked from jimmyhchan/intro.js
Last active January 2, 2016 13:58
Show Gist options
  • Save seriousManual/8313206 to your computer and use it in GitHub Desktop.
Save seriousManual/8313206 to your computer and use it in GitHub Desktop.
//whitespaces added for clarification
(function(){
dust.register("intro",body_0);
function body_0(chk,ctx){
return chk.write("Hello ").reference(ctx._get(false, ["name"]),ctx,"h").write("!");
}
return body_0;
})();
var fs = require('fs');
var dust = require('dustjs-linkedin');
var tmplSource = fs.readFileSync(__dirname + '/intro.js').toString();
var tmpl = createTemplate(tmplSource, 'intro');
tmpl({name: 'fooobar'}, function(error, result) {
console.log(arguments);
});
function createTemplate(tmplSource, name) {
dust.loadSource(tmplSource);
return function(data, callback) {
dust.render(name, data, callback);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment