Merge branch 'partial-lookup'
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 ff5c958, f25c14d · Browse files · 5 files·+28 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+28 added−10 removed
- tests:+13 added−7 removed
- other:+15 added−3 removed
Provenance
- Commit
647bb41- Tree
3d8c6ab- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent 1
ff5c958- Parent 2
f25c14d
5 files changed+28 added−10 removed
modified:examples/jade/views/user/list.jade+1 added-1 removed
1 - if (users.length)2 h1 Users3- #users!= partial('user/user', users)3+ #users!= partial('user', users)modified:lib/express/view/partial.js+13 added-1 removed
27 unmodified lines2829303132323334353637383940414243444546474849505152535455565721 unmodified lines27 unmodified lines
var Partial = exports = module.exports = function Partial(view, options) { options = options || {}; View.call(this, view, options); this.path = this.dirname + '/_' + basename(this.path); this.path = this.resolvePartialPath(this.dirname);};
/** * Inherit from `View.prototype`. */
Partial.prototype.__proto__ = View.prototype;
/** * Resolve partial view path. * * @param {String} dir * @return {String} * @api public */
Partial.prototype.resolvePartialPath = function(dir){ return dir + '/_' + basename(this.path);};
/** * Resolve partial object name from the view path. * * Examples: *21 unmodified linesmodified:lib/express/view.js+1 added-1 removed
105 unmodified lines106 } else {107 options.scope = options.object;108 }109 }110- return self.render(view, options);110+ return self.render(view, options, null, parent);111 }112 113 // Collection support114 var collection = options.collection;145 unmodified linesadded:test/fixtures/forum/_thread.jade+1 added
1+h1 Forum Threadmodified:test/view.test.js+12 added-7 removed
101 unmodified lines102 resolve('forum thread post.ejs').should.equal('forumThreadPost');103 },104 105 'test Partial#path for partials': function(){106+ var fixtures = __dirname + '/fixtures';107+ 106- var view = new Partial('user.ejs', { root: '/www' });107- view.path.should.equal('/www/_user.ejs');108+ var view = new Partial('user.jade', { root: fixtures });109+ view.path.should.equal(fixtures + '/_user.jade');110 109- var view = new Partial('user', { parentView: view, root: '/www' });110- view.path.should.equal('/www/_user.ejs');111+ var view = new Partial('user', { parentView: view, root: fixtures });112+ view.path.should.equal(fixtures + '/_user.jade');113 114 var view = new Partial('forum/thread', { parentView: view });113- view.path.should.equal('/www/forum/_thread.ejs');115+ view.path.should.equal(fixtures + '/forum/_thread.jade');116 115- var view = new Partial('forum/thread.jade', { root: '/www' });116- view.path.should.equal('/www/forum/_thread.jade');117+ var view = new Partial('forum/thread.jade', { root: fixtures });118+ view.path.should.equal(fixtures + '/forum/_thread.jade');119+120+ var view = new Partial('thread', { parentView: view });121+ view.path.should.equal(fixtures + '/forum/_thread.jade');122 },123 124 'test #render()': function(){125 var app = create();645 unmodified lines