Working on test for ../../omg

This commit is contained in:
Alan Johnson
2010-08-03 00:05:24 -04:00
parent edb6b238d8
commit 7e036fb952
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -142,6 +142,7 @@ Handlebars.Compiler.prototype = {
// each function made internally needs a unique IDs. These are locals, so they
// don't need to be globally unique, just per compiler
console.log("In block " + mustache);
var fnId = "fn" + this.pointer.toString();
this.fn += "var " + fnId + " = function(context) {" + result + "}; ";
+9 -1
View File
@@ -46,7 +46,15 @@ test("block with complex lookup", function() {
var string = "{{#goodbyes}}{{text}} cruel {{../name}}! {{/goodbyes}}"
var hash = {name: "Alan", goodbyes: [{text: "goodbye"}, {text: "Goodbye"}, {text: "GOODBYE"}]};
shouldCompileTo(string, hash, "goodbye cruel Alan! Goodbye cruel Alan! GOODBYE cruel Alan! ");
shouldCompileTo(string, hash, "goodbye cruel Alan! Goodbye cruel Alan! GOODBYE cruel Alan! ",
"Templates can access variables in contexts up the stack with relative path syntax");
});
test("block with deep nested complex lookup", function() {
var string = "{{#outer}}Goodbye {{#inner}}cruel {{../../omg}}{{/inner}}{{/outer}}";
var hash = {omg: "OMG!", outer: { inner: { text: "goodbye" } } };
shouldCompileTo(string, hash, "Goodbye cruel OMG!");
});
test("block helper", function() {