Skip to content
Myr

Fixed view layout bug. Closes #720

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

preventing custom relative layouts such as: views/ users/ user-layout.jade

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 35370da · Browse files · 1 file+8 added−5 removed
This commit

State

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

Diff stats

1 file+8 added−5 removed

  • other:+8 added−5 removed

1 file+8 added−5 removed

modified:lib/view.js+8 added-5 removed
91 unmodified lines
92 * @api private93 */9495exports.lookup = function(view, options){96 var orig = view = new View(view, options);96 var orig = view = new View(view, options)97 , partial = options.isPartial98 , layout = options.isLayout;99100 // Try _ prefix ex: ./views/_<name>.jade101 // taking precedence over the direct path102 if (partial) {103 view = new View(orig.prefixPath, options);104 if (!view.exists) view = orig;105 }106107 // Try index ex: ./views/user/index.jade105 if (!view.exists) view = new View(orig.indexPath, options);108 if (!layout && !view.exists) view = new View(orig.indexPath, options);109110 // Try ../<name>/index ex: ../user/index.jade111 // when calling partial('user') within the same dir109 if (!view.exists && !options.isLayout) view = new View(orig.upIndexPath, options);112 if (!layout && !view.exists) view = new View(orig.upIndexPath, options);113114 // Try root ex: <root>/user.jade115 if (!view.exists) view = new View(orig.rootPath, options);116
47 unmodified lines
164 // Merge locals165 if (locals) merge(options, locals);166167 // Partials dont need layouts165 options.renderPartial = true;168 options.isPartial = true;169 options.layout = false;170171 // Deduce name from view path172 var name = options.as || partial.resolveObjectName(view);
189 unmodified lines
362363 // capture attempts364 options.attempts = [];365363 var partial = options.renderPartial366 var partial = options.isPartial367 , layout = options.layout;368369 // Layout support370 if (true === layout || undefined === layout) {
90 unmodified lines