Skip to content

Instantly share code, notes, and snippets.

@clineamb
Last active January 30, 2016 16:43
Nunjucks 2.3.0 + Express 4.13.4
var nunjucks = require('nunjucks')
, express = require('express')
, app = express()
, env
;
// view engine setup
app.set('views', path.join(__dirname, 'views'));
env = new nunjucks.Environment(
new nunjucks.FileSystemLoader(app.get('views'))
, { autoescape: true }
);
// add filters to env example
env.addFilter('asset', function(assetpath) {
var asset_url = "path/to/assets/";
return asset_url + assetpath;
return assetpath;
});
env.express(app);
app.set('view engine', 'nunjs'); // lets make our extension shorter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment