Skip to content

Commit

Permalink
Merge pull request hapijs#848 from gpierret/master
Browse files Browse the repository at this point in the history
Template settings override fix
  • Loading branch information
Eran Hammer committed May 13, 2013
2 parents 4f6826c + e50b12b commit 343e2c5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ internals.Manager.prototype.render = function (filename, context, options, callb

var rendered = null;

if (!engine.config.layout) {
if (!settings.layout) {

// No layout

Expand All @@ -177,14 +177,14 @@ internals.Manager.prototype.render = function (filename, context, options, callb
return callback(Boom.internal(err.message, err));
}

return callback(null, rendered, engine.config);
return callback(null, rendered, settings);
}

// With layout

if (context.hasOwnProperty(engine.config.layoutKeyword)) {
if (context.hasOwnProperty(settings.layoutKeyword)) {

return callback(Boom.internal('settings.layoutKeyword conflict', { context: context, keyword: engine.config.layoutKeyword }));
return callback(Boom.internal('settings.layoutKeyword conflict', { context: context, keyword: settings.layoutKeyword }));
}

self._compile('layout' + engine.suffix, engine, settings, function (err, layout) {
Expand All @@ -196,14 +196,14 @@ internals.Manager.prototype.render = function (filename, context, options, callb
var layoutContext = Utils.clone(context);

try {
layoutContext[engine.config.layoutKeyword] = compiled(context, settings.runtimeOptions);
layoutContext[settings.layoutKeyword] = compiled(context, settings.runtimeOptions);
rendered = layout(layoutContext, settings.runtimeOptions);
}
catch (err) {
return callback(Boom.internal(err.message, err));
}

return callback(null, rendered, engine.config);
return callback(null, rendered, settings);
});
});
};
Expand Down

0 comments on commit 343e2c5

Please sign in to comment.