visionmedia/jade — pull request #1556 by jeromew (2014-06-14 23:32:12+00:00)
Title: mixin precompilation

Hello,

This PR is hopefully an acceptable way to separate the compilation of the mixins from the compilation of the templates.

In other words, you can compile mixins once (as a bundle or one by one) and then the compilation of a template will not need to recompile all the mixins :-)

I have used it for some time now and did not run into issues. All tests are passing.

I think this might be a nice addition for the dynamic capabilities of jade
- combined with the dynamic mixin
- to allow for easier componentization of mixins (as npm modules for instance)

Tell me what you think.

Example code:

mixin.jade
````
mixin dynamic(world)
| hello #{world}
````

template.jade
````
+dynamic("world")
````

index.js
````
var jade = require('jade');
var locals = {
keepMixins: true,
jade_mixins: {}
};

var mixin = jade.renderFile('mixin.jade', locals);
var html = jade.renderFile('template.jade', locals);
console.log(html);
````

=> result
````
hello world
````