public
Last active

Express 3.0 flash messages with view helper

  • Download Gist
app.js
JavaScript
1 2 3 4 5 6
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();
})

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.