-
-
Save jimmyhchan/8309666 to your computer and use it in GitHub Desktop.
Revisions
-
jimmyhchan revised this gist
Jan 8, 2014 . 2 changed files with 3 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,3 @@ //whitespaces added for clarification module.exports = (function(){ dust.register("intro",body_0); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,25 +2,10 @@ var dust = require('dustjs-linkedin'); var templateName = 'intro'; // this adds intro to dust.cache require('./' + templateName); dust.render('intro', {name:'fooooo'}, function(error, result) { console.log(result); }); -
Manuel Ernst created this gist
Jan 7, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ var dust = require('dustjs-linkedin'); //whitespaces added for clarification module.exports = (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; })(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ var dust = require('dustjs-linkedin'); var templateName = 'intro'; var serializedTemplate = require('./' + templateName); function createCallableTemplate(name, tmpl) { return function(context, callback) { var master = callback ? new dust.Stub(callback) : new dust.Stream(); dust.nextTick(function() { if(typeof tmpl === 'function') { tmpl(master.head, dust.Context.wrap(context, name)).end(); } else { dust.onError(new Error('Template [' + name + '] cannot be resolved to a Dust function')); } }); return master; }; } var usableTemplate = createCallableTemplate(templateName, serializedTemplate); usableTemplate({name:'fooooo'}, function(error, result) { console.log(result); });