Skip to content

Commit

Permalink
Save nunjuck env reference in express app settings (#829)
Browse files Browse the repository at this point in the history
* Save nunjuck env reference in express app settings

* Add test for express nunjucks env reference
  • Loading branch information
lukechilds authored and carljm committed Aug 31, 2016
1 parent 6a6cffa commit 0c3a03b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ var Environment = Obj.extend({
};

app.set('view', NunjucksView);
app.set('nunjucksEnv', this);
return this;
},

Expand Down
5 changes: 5 additions & 0 deletions tests/express/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var path = require('path');
var express = require('express');
var expect = require('expect.js');
var request = require('supertest');
var nunjucks = require('../../');

Expand All @@ -18,6 +19,10 @@ describe('express', function() {
env.express(app);
});

it('should have reference to nunjucks env', function() {
expect(app.settings.nunjucksEnv).to.be(env);
});

it('should render a view with extension', function(done) {
app.get('/', function(req, res) { res.render('about.njk'); });
request(app)
Expand Down

0 comments on commit 0c3a03b

Please sign in to comment.