Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Created July 8, 2012 13:22
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save glenjamin/3070950 to your computer and use it in GitHub Desktop.
Express 3.0 flash messages with view helper
app.use(require('connect-flash')());
// Expose the flash function to the view layer
app.use(function(req, res, next) {
res.locals.flash = function() { return req.flash() };
next();
})
@tj
Copy link

tj commented Jul 11, 2012

or res.locals.flash = req.flash.bind(req)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment