First pass at getting booleans working

This commit is contained in:
wycats
2010-07-31 18:26:26 -07:00
parent 755f854c50
commit 8714a581e9
2 changed files with 97 additions and 21 deletions
+15 -4
View File
@@ -1,17 +1,28 @@
module("basic context");
test("compiling with a basic context", function() {
var string = "Goodbye\n{{cruel}}\n{{world}}";
var string = "Goodbye\n{{cruel}}\n{{world}}!";
var template = Handlebars.compile(string);
result = template({cruel: "cruel", world: "world"});
equal("Goodbye\ncruel\nworld", result, "it works if all the required keys are provided");
equal(result, "Goodbye\ncruel\nworld!", "it works if all the required keys are provided");
});
test("comments", function() {
var string = "{{! Goodbye}}Goodbye\n{{cruel}}\n{{world}}";
var string = "{{! Goodbye}}Goodbye\n{{cruel}}\n{{world}}!";
var template = Handlebars.compile(string);
result = template({cruel: "cruel", world: "world"});
equal("Goodbye\ncruel\nworld", result, "it works if all the required keys are provided");
equal("Goodbye\ncruel\nworld!", result, "it works if all the required keys are provided");
});
test("boolean", function() {
var string = "{{#goodbye}}GOODBYE {{/goodbye}}cruel {{world}}!"
var template = Handlebars.compile(string);
result = template({goodbye: true, world: "world"});
equal("GOODBYE cruel world!", result, "booleans work when true");
result = template({goodbye: false, world: "world"});
equal("cruel world!", result, "booleans work when true");
});