I am thinking of using Jade templates on client side (with BackboneJS). Seems like I can use jadeify. But was wondering, how does it work? Does it download each template 1 by 1 or compile all templates on serverside then serve a "compiled" templates file to the client? Looking at the source, it looks surprisingly short:
https://github.com/substack/node-jadeify/blob/master/jadeify.js
var views = require('jadeify/views'); ...
module.exports = function (file, vars, opts) {
...
return $(jade.render(views[file], opts));
};
Line 1: can I even require a folder like that? Can I say views is now an array of scripts under that directory? That appear to be the case from Line 5, where views[file] is used.
But it calls jade.render. Won't it be more efficient to call jade.compile and cache it first? Or is it already cached somewhere?