1"use strict";
2
3var path = require('path');
4module.exports = function express(env, app) {
5  function NunjucksView(name, opts) {
6    this.name = name;
7    this.path = name;
8    this.defaultEngine = opts.defaultEngine;
9    this.ext = path.extname(name);
10    if (!this.ext && !this.defaultEngine) {
11      throw new Error('No default engine was specified and no extension was provided.');
12    }
13    if (!this.ext) {
14      this.name += this.ext = (this.defaultEngine[0] !== '.' ? '.' : '') + this.defaultEngine;
15    }
16  }
17  NunjucksView.prototype.render = function render(opts, cb) {
18    env.render(this.name, opts, cb);
19  };
20  app.set('view', NunjucksView);
21  app.set('nunjucksEnv', env);
22  return env;
23};