Skip to content

Instantly share code, notes, and snippets.

@cjroth
Created September 1, 2014 08:48
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 cjroth/59f80f1604e86b57b75e to your computer and use it in GitHub Desktop.
Save cjroth/59f80f1604e86b57b75e to your computer and use it in GitHub Desktop.
node/express.js - include commonly used view locals in every view for convenience
var path = require('path');
var _ = require('underscore');
var moment = require('moment');
var config = require('../config');
var pluralize = require('pluralize');
module.exports = function(app) {
if (app.get('env') === 'development') {
app.locals.pretty = true;
}
app.locals.basedir = path.join(__dirname, '../views');
app.locals.config = config;
app.locals.env = app.get('env');
app.locals._ = _;
app.locals.moment = moment;
app.locals.pluralize = pluralize;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment