Skip to content

Commit

Permalink
Merge pull request #1243 from lawnsea/nested-partial-blocks
Browse files Browse the repository at this point in the history
Walk up data frames for nested @partial-block
  • Loading branch information
wycats committed Sep 10, 2016
2 parents 11b99b3 + 2169600 commit 7535e48
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/handlebars/runtime.js
Expand Up @@ -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];
}
Expand Down
23 changes: 23 additions & 0 deletions spec/partials.js
Expand Up @@ -270,6 +270,20 @@ describe('partials', function() {
true,
'success');
});
it('should render nested partial blocks', function() {
shouldCompileToWithPartials(
'<template>{{#> outer}}{{value}}{{/outer}}</template>',
[
{value: 'success'},
{},
{
outer: '<outer>{{#> nested}}<outer-block>{{> @partial-block}}</outer-block>{{/nested}}</outer>',
nested: '<nested>{{> @partial-block}}</nested>'
}
],
true,
'<template><outer><nested><outer-block>success</outer-block></nested></outer></template>');
});
});

describe('inline partials', function() {
Expand Down Expand Up @@ -309,6 +323,15 @@ describe('partials', function() {
true,
'success');
});
it('should render nested inline partials', function() {
shouldCompileToWithPartials(
'{{#*inline "outer"}}{{#>inner}}<outer-block>{{>@partial-block}}</outer-block>{{/inner}}{{/inline}}' +
'{{#*inline "inner"}}<inner>{{>@partial-block}}</inner>{{/inline}}' +
'{{#>outer}}{{value}}{{/outer}}',
[{value: 'success'}, {}, {}],
true,
'<inner><outer-block>success</outer-block></inner>');
});
});

it('should pass compiler flags', function() {
Expand Down

0 comments on commit 7535e48

Please sign in to comment.