Skip to content
Myr

Added `app.dynamicLocal(name, fn)`

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 e899a54 · Browse files · 1 file+19 added−4 removed
This commit

State

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

Diff stats

1 file+19 added−4 removed

  • other:+19 added−4 removed

1 file+19 added−4 removed

modified:lib/http.js+19 added-4 removed
263 unmodified lines
264 * @api public265 */266267app.local = function(name, val){268 this._locals = this._locals || {};268 if (1 == arguments.length) return this._locals[name];269 this._locals[name] = val;270 return this;271};
15 unmodified lines
287 return this;288};289290/**292 * Register the given dynamic view helpers `obj`. This method293 * can be called several times to apply additional helpers.291 * Register the given dynamic view locals `obj`. This method292 * can be called several times to apply additional locals.293 *294 * @param {Object} obj295 * @return {Server} for chaining296 * @api public297 */298299app.dynamicLocals = function(obj){301 utils.merge(this._dynamicLocals, obj);300 for (var key in obj) {301 this.dynamicLocal(key, obj[key]);302 }303 return this;304};305306/**307 * Register a dynamic local with `name` and callback `fn(req, res)`.308 *309 * @param {String} name310 * @param {Object} fn311 * @return {Server} for chaining312 * @api public313 */314315app.dynamicLocal = function(name, fn){316 this._dynamicLocals[name] = fn;317 return this;318};319320/**321 * Map the given param placeholder `name`(s) to the given callback `fn`.322 *323 * Param mapping is used to provide pre-conditions to routes324 * which us normalized placeholders. This callback has the same
212 unmodified lines