/*! * Express - Contrib - messages * Copyright(c) 2010 TJ Holowaychuk * MIT Licensed */ module.exports = function (req, res) { return function (template, locals) { var flash = req.flash() , types = Object.keys(flash) , output = ''; if (types.length) { if (template) { locals = locals || {}; locals.messages = flash; res.render(template, locals, function (err, html) { if (html) { output = html; } }); } else { var buf = []; buf.push('
'); types.forEach(function (type) { var msgs = flash[type]; if (msgs) { buf.push(' '); } }); buf.push('
'); output = buf.join('\n'); } } return output; }; };