Skip to content
Myr

Added partial direct object support

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

these are now equivalent: before: partial(movie, { object: movieRecord }) after: partial(movie, movieRecord)

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 221bc4c · Browse files · 2 files+8 added−3 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+8 added−3 removed

  • tests:+5 added−2 removed
  • other:+3 added−1 removed

2 files+8 added−3 removed

modified:lib/express/view.js+3 added-1 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
6 unmodified lines
119 // Allow collection to be passed as second param120 if (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 }
191 unmodified lines
modified:test/view.test.js+5 added-2 removed
486 unmodified lines
487 'test #partial() object': function(assert){488 var app = create();489490 app.get('/', function(req, res, next){491 res.send(res.partial('item.jade', 'Wahoo'));491 res.send(res.partial('movie.jade', {492 title: 'Foobar'493 , director: 'Tim Burton'494 }));495 });496497 assert.response(app,498 { url: '/' },496 { body: '<li>Wahoo</li>\n' });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();
147 unmodified lines