From 34f553940cd5e9fba5ca6062333f42ba741b700a Mon Sep 17 00:00:00 2001 From: nanalelfe Date: Sun, 24 Jul 2016 23:14:34 -0400 Subject: Fixed /send_message error/success message show up. --- node_modules/express-messages/index.js | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 node_modules/express-messages/index.js (limited to 'node_modules/express-messages/index.js') diff --git a/node_modules/express-messages/index.js b/node_modules/express-messages/index.js new file mode 100644 index 0000000..099ffa3 --- /dev/null +++ b/node_modules/express-messages/index.js @@ -0,0 +1,43 @@ + +/*! + * 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('
    '); + msgs.forEach(function (msg) { + buf.push('
  • ' + msg + '
  • '); + }); + buf.push('
'); + } + }); + buf.push('
'); + output = buf.join('\n'); + } + } + + return output; + }; +}; -- cgit v1.2.3