UNPKG

@balderdash/sails-edge

Version:

API-driven framework for building realtime apps, using MVC conventions (based on Express and Socket.io)

51 lines (43 loc) 1.1 kB
/** * Module dependencies */ var _ = require('lodash'), util = require('sails-util'); /** * default locals * * Always share some basic metadata with views. * Roughly analogous to `app.locals` in Express. * * > Application local variables are provided to all templates rendered * > within the application. This is useful for providing helper functions * > to templates, as well as app-level data. * > * > http://expressjs.com/api.html#app.locals * * @param {Request} req * @param {Response} res * @api private */ module.exports = function _mixinLocals(req, res) { // TODO: // Actually take advantage of `app.locals` // for this logic. // TODO: // we might look at pruning the stuff being // passed in here, to improve the optimizations // of Express's production view cache. _.extend(res.locals, { _: _, util: util, session: req.session, req: req, res: res, sails: req._sails }); // May be deprecated in an upcoming release: res.locals.title = req._sails.config.appName; if (req.options.action) { ' | ' + util.str.capitalize(req.param('action')); } };