Skip to content
Myr

Merge branch 'feature/root-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 1e46218, 5d6ce25 · Browse files · 5 files+29 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

5 files+29 added−3 removed

  • tests:+23 added−0 removed
  • other:+6 added−3 removed

5 files+29 added−3 removed

modified:lib/view.js+6 added-3 removed
283 unmodified lines
284285 // Populate view286 var orig = view = new View(view, options);287288 // Try _ prefix ex: ./views/_user.jade288 // Try _ prefix ex: ./views/_<name>.jade289 if (!view.exists) view = new View(orig.prefixPath, options);290 291 // Try index ex: ./views/user/index.jade292 if (!view.exists) view = new View(orig.indexPath, options);
1 unmodified line
294 // Try ../<name>/index ex: ../user/index.jade295 // when calling partial('user') within the same dir296 if (!view.exists && !options.isLayout) view = new View(orig.upIndexPath, options);297298 // Try layout relative to the "views" dir 299 if (!view.exists && options.isLayout) view = new View(orig.rootPath, options);298 // Try root ex: <root>/user.jade299 if (!view.exists) view = new View(orig.rootPath, options);300301 // Try root _ prefix ex: <root>/_user.jade302 if (!view.exists && partial) view = new View(view.prefixPath, options);303304 // Does not exist305 if (!view.exists) {306 if (app.enabled('hints')) hintAtViewPaths(orig, options);307 throw new Error('failed to locate view "' + orig.view + '"');
73 unmodified lines
added:test/fixtures/nested/partial.jade+1 added
1!= partial('stats', { hits: 15, misses: 1 })
added:test/fixtures/nested/partial2.jade+1 added
1!= partial('messages')
added:test/fixtures/_messages.jade+1 added
1p Testing
modified:test/view.test.js+20 added
597 unmodified lines
598599 assert.response(app,600 { url: '/stats/callback/2' },601 { body: 'got: <p>Hits 12</p><p>Misses 1</p>' });602603 // root lookup604605 app.get('/root', function(req, res){606 res.partial('nested/partial');607 });608609 assert.response(app,610 { url: '/root' },611 { body: '<p>Hits 15</p><p>Misses 1</p>' });612613 // root _* lookup614615 app.get('/root/underscore', function(req, res){616 res.partial('nested/partial2');617 });618619 assert.response(app,620 { url: '/root/underscore' },621 { body: '<p>Testing</p>' });622 },623 624 'test #partial() with several calls': function(){625 var app = create();
419 unmodified lines