Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template: inheritance: fix for sub content from first invocation appearing in the second #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}}{{$sub}}D{{/sub}}{{/parent}}{{>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() {
Expand Down