From 831d2343584ac20b22184d576785a2bba9564c29 Mon Sep 17 00:00:00 2001 From: Yuriy Nemtsov Date: Thu, 8 Jun 2017 15:49:39 -0400 Subject: [PATCH] bugfix: template: sub content from first invocation must not appear in the second --- lib/template.js | 2 +- test/index.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/template.js b/lib/template.js index 14f396d..2848243 100644 --- a/lib/template.js +++ b/lib/template.js @@ -52,7 +52,7 @@ var Hogan = {}; // check to see that if we've instantiated this partial before var template = partials[partial.name]; - if (partial.instance && partial.base == template) { + if (partial.instance && !partial.subs && partial.base == template) { return partial.instance; } diff --git a/test/index.js b/test/index.js index ec0777e..1c6374d 100644 --- a/test/index.js +++ b/test/index.js @@ -1035,6 +1035,13 @@ test("Lambdas work in multi-level inheritance", function() { is(child, 'changed c - changed p - changed o - changed g', 'should be changed child value'); }); +test("Sub content from first invocation must not appear in the second", function() { + const main = Hogan.compile('{{parent}}'); + const parent = Hogan.compile('{{>child}}'); + const child = Hogan.compile('{{$sub}}{{/sub}}'); + is(main.render({}, { 'parent': parent, 'child': child }), 'D'); +}); + /* Safety tests */ test("Updates object state", function() {