Skip to content

Instantly share code, notes, and snippets.

@clineamb
Last active January 30, 2016 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clineamb/cc94e64bc7b2b65c55cf to your computer and use it in GitHub Desktop.
Save clineamb/cc94e64bc7b2b65c55cf to your computer and use it in GitHub Desktop.
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