From 7b1fdf814c5ce9f7b061696a8d7ede392d8d0f3b Mon Sep 17 00:00:00 2001 From: kpdecker Date: Fri, 4 Sep 2015 09:09:17 -0500 Subject: Fix use of decorators within partials If a decorator is used within a partial but not in the calling template, the hash is not passed in. For now error on the side of always including as just assigning values has minimal overhead. Fixes #1089 --- lib/handlebars/runtime.js | 2 +- spec/regressions.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js index 6b31a7b..52d9b94 100644 --- a/lib/handlebars/runtime.js +++ b/lib/handlebars/runtime.js @@ -161,7 +161,7 @@ export function template(templateSpec, env) { if (templateSpec.usePartial) { container.partials = container.merge(options.partials, env.partials); } - if (templateSpec.useDecorators) { + if (templateSpec.usePartial || templateSpec.useDecorators) { container.decorators = container.merge(options.decorators, env.decorators); } } else { diff --git a/spec/regressions.js b/spec/regressions.js index ae0797e..cca126e 100644 --- a/spec/regressions.js +++ b/spec/regressions.js @@ -212,4 +212,12 @@ describe('Regressions', function() { }; shouldCompileToWithPartials(string, [{}, {}, partials], true, 'doctypelayoutsubcontent'); }); + it('GH-1089: should support failover content in multiple levels of inline partials', function() { + var string = '{{#> layout}}{{/layout}}'; + var partials = { + doctype: 'doctype{{> content}}', + layout: '{{#> doctype}}{{#*inline "content"}}layout{{#> subcontent}}subcontent{{/subcontent}}{{/inline}}{{/doctype}}' + }; + shouldCompileToWithPartials(string, [{}, {}, partials], true, 'doctypelayoutsubcontent'); + }); }); -- cgit v1.1