Prevent context overwrite by replaceStack

Fixes #408.
This commit is contained in:
kpdecker
2013-01-13 22:35:03 -06:00
parent 4f54f62abc
commit 8961298859
2 changed files with 26 additions and 7 deletions
+12
View File
@@ -1282,3 +1282,15 @@ test("Passing falsy values to Handlebars.compile throws an error", function() {
CompilerContext.compile(null);
}, "You must pass a string to Handlebars.compile. You passed null");
});
test('GH-408: Multiple loops fail', function() {
var context = [
{ name: "John Doe", location: { city: "Chicago" } },
{ name: "Jane Doe", location: { city: "New York"} }
];
var template = CompilerContext.compile('{{#.}}{{name}}{{/.}}{{#.}}{{name}}{{/.}}');
var result = template(context);
equals(result, "John DoeJane DoeJohn DoeJane Doe", 'It should output twice');
});