"use strict";

var UTA = require('underscore-template-additions');
var engines = require('consolidate');

var templates = new UTA();

module.exports = function(app, viewDirectory) {
  if (app.get('env') === 'production') {
    templates.cacheTemplates = true;
  }
  app.set('views', viewDirectory);
  app.engine('html', templates.forExpress());
  app.engine('txt', engines.hogan);
};

"use strict";

var UTA = require('underscore-template-additions');
var engines = require('consolidate');

module.exports = function(app, viewDirectory) {
  var templates = new UTA();

  if (app.get('env') === 'production') {
    templates.cacheTemplates = true;
  }
  app.set('views', viewDirectory);
  app.engine('html', templates.forExpress());
  app.engine('txt', engines.hogan);
};

Make sure each app has its own template instance
Make sure each app has its own template instance

If the templates instance is created outside of the configuration block
then the hosting app and the instance app both end up sharing the same
instance of the templates module. Because both of these apps have an
'index.html' view, they end up treading on each other and getting in a
tangle.

This simply moves the template instance creation into the template
configuration block so it's not cached by node's module system.
