diff options
author | Yehuda Katz <wycats@gmail.com> | 2016-09-10 07:10:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-10 07:10:36 -0700 |
commit | 7535e48a7969229f44489124a8ef07bd17363f06 (patch) | |
tree | 0019d7c0267de63510d2a7b4fe19e349d1b45402 | |
parent | 11b99b361d5c76e9f842881b36af9b726494fe85 (diff) | |
parent | 21696005cd9e5a3ea2150431df44fd13da2c405c (diff) | |
download | handlebars.js-origin/HEAD.zip handlebars.js-origin/HEAD.tar.gz handlebars.js-origin/HEAD.tar.bz2 |
Merge pull request #1243 from lawnsea/nested-partial-blocksHEADorigin/masterorigin/HEADmaster
Walk up data frames for nested @partial-block
-rw-r--r-- | lib/handlebars/runtime.js | 7 | ||||
-rw-r--r-- | spec/partials.js | 23 |
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js index 55eb1c1..7426f1f 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 d3ead74..d6baba5 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( + '<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() { |