Merge pull request #1243 from lawnsea/nested-partial-blocks
Walk up data frames for nested @partial-block
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user