Skip to content
Myr

`app.local()` and `res.local()` return for chaining

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 f98896f · Browse files · 3 files+25 added−8 removed
This commit

State

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

Diff stats

3 files+25 added−8 removed

  • tests:+17 added−0 removed
  • other:+8 added−8 removed

3 files+25 added−8 removed

modified:lib/http.js+4 added-4 removed
258 unmodified lines
259 * local previously assigned to `name`.260 *261 * @param {String} name262 * @param {Mixed} val263 * @return {Mixed} val263 * @return {HTTPServer} for chaining264 * @api public265 */266267app.local = function(name, val){268 this._locals = this._locals || {};269 return undefined === val270 ? this._locals[name]271 : this._locals[name] = val;269 if (1 == arguments.length) return this._locals[name];270 this._locals[name] = val;271 return this;272};273274/**275 * Assign several locals with the given `obj`,
246 unmodified lines
modified:lib/response.js+4 added-4 removed
424 unmodified lines
425 * local previously assigned to `name`.426 *427 * @param {String} name428 * @param {Mixed} val429 * @return {Mixed} val429 * @return {ServerResponse} for chaining430 * @api public431 */432433res.local = function(name, val){434 this._locals = this._locals || {};435 return undefined === val436 ? this._locals[name]437 : this._locals[name] = val;435 if (1 == arguments.length) return this._locals[name];436 this._locals[name] = val;437 return this;438};439440/**441 * Assign several locals with the given `obj`,
14 unmodified lines
modified:test/view.test.js+17 added
981 unmodified lines
982 assert.response(app,983 { url: '/' },984 { body: '<p>This is actually jade :)</p>' });985 },986987 'test app.local()': function(){988 var app = create();989990 app991 .local('open', '<?')992 .local('close', '?>')993 .local('title', 'Wahoo');994995 app.get('/video', function(req, res, next){996 res.render('video.ejs', { layout: false });997 });998 999 assert.response(app,1000 { url: '/video' },1001 { body: '<h1>Wahoo</h1>' });1002 },1003 1004 'test res.local()': function(){1005 var app = create();1006
163 unmodified lines