Boolean("false") === true

This commit is contained in:
tomhuda
2013-01-18 16:42:27 -08:00
parent cd9895061b
commit ce82bef6f1
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -117,7 +117,7 @@ var Handlebars = require('./base');
Handlebars.AST.BooleanNode = function(bool) {
this.type = "BOOLEAN";
this.bool = bool;
this.stringModeValue = Boolean(bool);
this.stringModeValue = bool === "true";
};
Handlebars.AST.CommentNode = function(comment) {
+4 -3
View File
@@ -1194,16 +1194,17 @@ test("when inside a block in String mode, .. passes the appropriate context in t
});
test("in string mode, information about the types is passed along", function() {
var template = CompilerContext.compile('{{tomdale "need" dad.joke true}}', { stringParams: true });
var template = CompilerContext.compile('{{tomdale "need" dad.joke true false}}', { stringParams: true });
var helpers = {
tomdale: function(desire, noun, bool, options) {
tomdale: function(desire, noun, trueBool, falseBool, options) {
equal(options.types[0], 'STRING', "the string type is passed");
equal(options.types[1], 'ID', "the expression type is passed");
equal(options.types[2], 'BOOLEAN', "the expression type is passed");
equal(desire, "need", "the string form is passed for strings");
equal(noun, "dad.joke", "the string form is passed for expressions");
equal(bool, true, "raw booleans are passed through");
equal(trueBool, true, "raw booleans are passed through");
equal(falseBool, false, "raw booleans are passed through");
return "Helper called";
}
};