Skip to content
Myr

Added layout lookup support relative to the page view

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

for example if you render ./views/forum/thread and ./views/forum/thread/layout.jade exists, it will be used, falling back on ./views/layout.jade.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 110b0fe · Browse files · 2 files+15 added−1 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+15 added−1 removed

  • other:+15 added−1 removed

2 files+15 added−1 removed

modified:lib/view/view.js+12 added
133 unmodified lines
134 return cache[ext] || (cache[ext] = require(this.engine));135});136137/**138 * Return root path alternative.139 *140 * @return {String}141 * @api public142 */143144View.prototype.__defineGetter__('rootPath', function(){145 this.relative = false;146 return this.resolvePath();147});148149/**150 * Return index path alternative.151 *152 * @return {String}153 * @api public
57 unmodified lines
modified:lib/view.js+3 added-1 removed
231 unmodified lines
232233 // Ensure view exists, or try ../index234 if (!view.exists && !options.isLayout) view = new View(orig.upIndexPath, options);235236 // Try layout relative to the "views" dir 237 if (!view.exists && options.isLayout) view = new View(orig.rootPath, options);238239 // Dynamic helper support240 if (false !== options.dynamicHelpers) {241 // cache242 if (!this.__dynamicHelpers) {
41 unmodified lines
284 if (layout) {285 options.isLayout = true;286 options.layout = false;287 options.body = str;285 options.relative = false;288 self.render(layout, options, fn, view);289 } else if (partial) {290 return str;291 } else if (fn) {
5 unmodified lines