Fix bug where inverse section was being passed to subsequent helpers

This commit is contained in:
Yehuda Katz
2011-12-27 00:30:24 -08:00
parent cb04822812
commit e57e626480
2 changed files with 11 additions and 1 deletions
+1
View File
@@ -181,6 +181,7 @@ Handlebars.JavaScriptCompiler = function() {};
this.declare('inverse', programGuid);
this.opcode('invokeProgram', null, params.length, !!block.mustache.hash);
this.declare('inverse', null);
this.opcode('append');
},
+10 -1
View File
@@ -983,4 +983,13 @@ test("GH-94: Cannot read property of undefined", function() {
var string = "{{#books}}{{title}}{{author.name}}{{/books}}";
shouldCompileTo(string, data, "The origin of speciesCharles DarwinLazarillo de Tormes",
"Renders without an undefined property error");
});
});
test("GH-150: Inverted sections print when they shouldn't", function() {
var string = "{{^set}}not set{{/set}} :: {{#set}}set{{/set}}";
shouldCompileTo(string, {}, "not set :: ", "inverted sections run when property isn't present in context");
shouldCompileTo(string, {set: undefined}, "not set :: ", "inverted sections run when property is undefined");
shouldCompileTo(string, {set: false}, "not set :: ", "inverted sections run when property is false");
shouldCompileTo(string, {set: true}, " :: set", "inverted sections don't run when property is true");
});