Last active
August 29, 2015 13:56
-
-
Save realistschuckle/9165608 to your computer and use it in GitHub Desktop.
Revisions
-
Curtis Schlak revised this gist
Feb 23, 2014 . 1 changed file with 38 additions and 38 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,41 +1,41 @@ /*jslint anon:true, sloppy:true, nomen:true, white:true*/ YUI.add('addons-viewengine-jade', function(Y, NAME) { var jade = require('jade') , fs = require('fs') , cache = YUI.namespace('Env.Mojito.Jade') ; function JadeAdapter(config) { this.config = config || {}; } JadeAdapter.prototype = { render: function(data, mojitType, tmpl, adapter, meta, more) { var engine = this , tmplpath = tmpl['content-path'] ; this.compile(tmplpath, function(e, compiled) { if(more) { adapter.flush(compiled(data), meta); } else { adapter.done(compiled(data), meta); } }); } , compile: function(tmplpath, callback) { var cacheTemplates = (this.config.cacheTemplates === false)? false : true ; if(!cacheTemplates || !cache[tmplpath]) { fs.readFile(tmplpath, 'utf8', function(e, data) { var jade = require('jade') , compiled = jade.compile(data, {filename: tmplpath}) ; cache[tmplpath] = compiled; callback(e, compiled); }); } else { callback(null, cache[tmplpath]); } } }; Y.namespace('mojito.addons.viewEngines').jade = JadeAdapter; }, "0.0.1"); -
Curtis Schlak created this gist
Feb 23, 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,41 @@ /*jslint anon:true, sloppy:true, nomen:true, white:true*/ YUI.add('addons-viewengine-jade', function(Y, NAME) { var jade = require('jade') , fs = require('fs') , cache = YUI.namespace('Env.Mojito.Jade') ; function JadeAdapter(config) { this.config = config || {}; } JadeAdapter.prototype = { render: function(data, mojitType, tmpl, adapter, meta, more) { var engine = this , tmplpath = tmpl['content-path'] ; this.compile(tmplpath, function(e, compiled) { if(more) { adapter.flush(compiled(data), meta); } else { adapter.done(compiled(data), meta); } }); } , compile: function(tmplpath, callback) { var cacheTemplates = (this.config.cacheTemplates === false)? false : true ; if(!cacheTemplates || !cache[tmplpath]) { fs.readFile(tmplpath, 'utf8', function(e, data) { var jade = require('jade') , compiled = jade.compile(data, {filename: tmplpath}) ; cache[tmplpath] = compiled; callback(e, compiled); }); } else { callback(null, cache[tmplpath]); } } }; Y.namespace('mojito.addons.viewEngines').jade = JadeAdapter; }, "0.1.0");