diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js index 55eb1c1b0..7426f1f5e 100644 --- a/lib/handlebars/runtime.js +++ b/lib/handlebars/runtime.js @@ -197,7 +197,12 @@ export function wrapProgram(container, i, fn, data, declaredBlockParams, blockPa export function resolvePartial(partial, context, options) { if (!partial) { if (options.name === '@partial-block') { - partial = options.data['partial-block']; + let data = options.data; + while (data['partial-block'] === noop) { + data = data._parent; + } + partial = data['partial-block']; + data['partial-block'] = noop; } else { partial = options.partials[options.name]; } diff --git a/spec/partials.js b/spec/partials.js index d3ead7458..d6baba504 100644 --- a/spec/partials.js +++ b/spec/partials.js @@ -270,6 +270,20 @@ describe('partials', function() { true, 'success'); }); + it('should render nested partial blocks', function() { + shouldCompileToWithPartials( + '', + [ + {value: 'success'}, + {}, + { + outer: '{{#> nested}}{{> @partial-block}}{{/nested}}', + nested: '{{> @partial-block}}' + } + ], + true, + ''); + }); }); describe('inline partials', function() { @@ -309,6 +323,15 @@ describe('partials', function() { true, 'success'); }); + it('should render nested inline partials', function() { + shouldCompileToWithPartials( + '{{#*inline "outer"}}{{#>inner}}{{>@partial-block}}{{/inner}}{{/inline}}' + + '{{#*inline "inner"}}{{>@partial-block}}{{/inline}}' + + '{{#>outer}}{{value}}{{/outer}}', + [{value: 'success'}, {}, {}], + true, + 'success'); + }); }); it('should pass compiler flags', function() {