diff options
-rw-r--r-- | lib/handlebars/runtime.js | 2 | ||||
-rw-r--r-- | spec/partials.js | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js index 9dae284..744e6eb 100644 --- a/lib/handlebars/runtime.js +++ b/lib/handlebars/runtime.js @@ -136,7 +136,7 @@ export function template(templateSpec, env) { blockParams = templateSpec.useBlockParams ? [] : undefined; if (templateSpec.useDepths) { if (options.depths) { - depths = context !== options.depths[0] ? [context].concat(depths) : options.depths; + depths = context !== options.depths[0] ? [context].concat(options.depths) : options.depths; } else { depths = [context]; } diff --git a/spec/partials.js b/spec/partials.js index b2fc9e0..a9cd3dd 100644 --- a/spec/partials.js +++ b/spec/partials.js @@ -238,6 +238,12 @@ describe('partials', function() { var hash = {root: 'yes', dudes: [{name: 'Yehuda', url: 'http://yehuda'}, {name: 'Alan', url: 'http://alan'}]}; shouldCompileToWithPartials(string, [hash, {}, {dude: partial}, true], true, 'Dudes: Yehuda (http://yehuda) yes Alan (http://alan) yes '); }); + it('partials can access parents with custom context', function() { + var string = 'Dudes: {{#dudes}}{{> dude "test"}}{{/dudes}}'; + var partial = '{{name}} ({{url}}) {{root}} '; + var hash = {root: 'yes', dudes: [{name: 'Yehuda', url: 'http://yehuda'}, {name: 'Alan', url: 'http://alan'}]}; + shouldCompileToWithPartials(string, [hash, {}, {dude: partial}, true], true, 'Dudes: Yehuda (http://yehuda) yes Alan (http://alan) yes '); + }); it('partials can access parents without data', function() { var string = 'Dudes: {{#dudes}}{{> dude}}{{/dudes}}'; var partial = '{{name}} ({{url}}) {{root}} '; |