Skip to content
Myr

Merge branch 'partial-object'

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 · parents 03e7b5d, b08549a · Browse files · 2 files+24 added−6 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+24 added−6 removed

  • tests:+15 added−0 removed
  • other:+9 added−6 removed

2 files+24 added−6 removed

modified:lib/express/view.js+9 added-6 removed
103 unmodified lines
104 * - `collection` Array of objects, the name is derived from the view name itself. 105 * For example _video.html_ will have a object _video_ available to it.106 *107 * @param {String} view108 * @param {Object|Array} options or collection108 * @param {Object|Array} options, collection, or object109 * @return {String}110 * @api public111 */112
3 unmodified lines
116 view += ext;117 }118119 // Allow collection to be passed as second param120 if (options) {120 if (options && options.hasOwnProperty('length')) {121 options = { collection: options };121 if (options.hasOwnProperty('length')) {122 options = { collection: options };123 } else if (!options.collection && !options.locals && !options.object) {124 options = { object: options };125 }126 } else {127 options = {};128 }129124 // Defaults125 options = options || {};126130 // Inherit locals from parent131 options.locals = options.locals || {};132 utils.merge(options.locals, locals);133
186 unmodified lines
modified:test/view.test.js+15 added
482 unmodified lines
483 { url: '/' },484 { body: 'We have 5 cool pets\n' });485 },486 487 'test #partial() object': function(assert){488 var app = create();489490 app.get('/', function(req, res, next){491 res.send(res.partial('movie.jade', {492 title: 'Foobar'493 , director: 'Tim Burton'494 }));495 });496497 assert.response(app,498 { url: '/' },499 { body: '<li><div class="title">Foobar</div><div class="director">Tim Burton</div></li>' });500 },501 502 'test #partial() locals with collection': function(assert){503 var app = create();504505 app.get('/', function(req, res, next){
145 unmodified lines