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() {