summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-09-04 09:09:17 -0500
committerkpdecker <kpdecker@gmail.com>2015-09-04 09:09:17 -0500
commit7b1fdf814c5ce9f7b061696a8d7ede392d8d0f3b (patch)
tree5aa58f19c4b12da427fb2a7e847b052ec37b11dc
parentc7b28a65dab1f1bb370f258fd65796d74c7b53cb (diff)
downloadhandlebars.js-7b1fdf814c5ce9f7b061696a8d7ede392d8d0f3b.zip
handlebars.js-7b1fdf814c5ce9f7b061696a8d7ede392d8d0f3b.tar.gz
handlebars.js-7b1fdf814c5ce9f7b061696a8d7ede392d8d0f3b.tar.bz2
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
-rw-r--r--lib/handlebars/runtime.js2
-rw-r--r--spec/regressions.js8
2 files changed, 9 insertions, 1 deletions
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');
+ });
});