Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Created January 16, 2017 19:15
Show Gist options
  • Save daliborgogic/fdd31ff0fac7bdfd94b855a50be92021 to your computer and use it in GitHub Desktop.
Save daliborgogic/fdd31ff0fac7bdfd94b855a50be92021 to your computer and use it in GitHub Desktop.
module.exports = function (req, res, next) {
var render = res.render;
res.render = function () {
var viewName = arguments[0],
withoutExtension = viewName.replace(/\.[a-z]+$/i, ""),
bodyClass = withoutExtension.replace(/\//g, "-");
res.locals.bodyClass = bodyClass;
render.apply(this, arguments);
};
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment