publicclass/express-partials — pull request #4 by shimaore (2012-06-25 20:41:14+00:00)
Title: Allow multiple instances with different setup

The implementation I proposed earlier doesn't deal well with different setup for views and partials using multiple Express processes in parallel.

Here's a simplified example:

var express_partials = require('express-partials');

/* server `express1` uses jade */
express1.set('view engine','jade');
partials1 = express_partials();
partials1.register('html','jade'); /* .html files are actually jade files */
express1.use(partials1);

/* server `express2` uses ejs */
express2.set('view engine','ejs');
partials2 = express_partials();
partials2.register('html','ejs'); /* .html files are actually ejs files */
express2.use(partials1);

Previously, the last `register('html',...')` called would override the options for both, breaking the other server.

Notes:
* I didn't realign the code in `index.js`, to keep the patch as simple as possible; basically all the module-level functions become instance-level functions;
* I updated the README, the changes in the case of a single Express server are very simple.
* I added a separate test set to test for the case with multiple instances.