Skip to content
Myr

Renamed `app.flashFormatters` to `app.formatters`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent c7c9606 · Browse files · 2 files+13 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−7 removed

  • tests:+1 added−1 removed
  • other:+12 added−6 removed

2 files+13 added−7 removed

modified:lib/request.js+12 added-6 removed
14 unmodified lines
15 , mime = require('mime');1617/**18 * Default flash formatters.19 *20 * @type Object19 */2023var flashFormatters = exports.flashFormatters = {21var defaultFormatters = exports.formatters = {22 s: function(val){23 return String(val);24 },25
176 unmodified lines
202 * and use the %s specifier to be replaced by the associated argument:203 *204 * req.flash('info', 'email has been sent to %s.', userName);205 *208 * To add custom formatters use the `exports.flashFormatters` object.206 * You may add addition formatters by defining `app.formatters`,207 * for example in the following snippet we define `%u` to uppercase208 * a string:209 *210 * app.formatters = {211 * u: function(val){212 * return String(val).toUpperCase();213 * }214 * };215 *216 * @param {String} type217 * @param {String} msg218 * @return {Array|Object|Number}219 * @api public
4 unmodified lines
224 var msgs = this.session.flash = this.session.flash || {};225 if (type && msg) {226 var i = 2227 , args = arguments222 , formatters = this.app.flashFormatters || {};223 formatters.__proto__ = flashFormatters;228 , formatters = this.app.formatters || {};229 formatters.__proto__ = defaultFormatters;230 msg = utils.miniMarkdown(utils.escape(msg));231 msg = msg.replace(/%([a-zA-Z])/g, function(_, format){232 var formatter = formatters[format];233 if (formatter) return formatter(args[i++]);
86 unmodified lines
modified:test/request.test.js+1 added-1 removed
132 unmodified lines
133 connect.cookieParser()134 , connect.session({ secret: 'something' })135 );136137 app.flashFormatters = {137 app.formatters = {138 u: function(val){139 return String(val).toUpperCase();140 }141 };
200 unmodified lines