diff options
Diffstat (limited to 'spec/basic.js')
-rw-r--r-- | spec/basic.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/basic.js b/spec/basic.js index 245022c..8aa54b9 100644 --- a/spec/basic.js +++ b/spec/basic.js @@ -97,6 +97,18 @@ describe("basic context", function() { frank: "Frank"}, "Frank", "functions are called with context arguments"); }); + it("pathed functions with context argument", function() { + shouldCompileTo("{{bar.awesome frank}}", + {bar: {awesome: function(context) { return context; }}, + frank: "Frank"}, + "Frank", "functions are called with context arguments"); + }); + it("depthed functions with context argument", function() { + shouldCompileTo("{{#with frank}}{{../awesome .}}{{/with}}", + {awesome: function(context) { return context; }, + frank: "Frank"}, + "Frank", "functions are called with context arguments"); + }); it("block functions with context argument", function() { shouldCompileTo("{{#awesome 1}}inner {{.}}{{/awesome}}", @@ -104,11 +116,27 @@ describe("basic context", function() { "inner 1", "block functions are called with context and options"); }); + it("depthed block functions with context argument", function() { + shouldCompileTo("{{#with value}}{{#../awesome 1}}inner {{.}}{{/../awesome}}{{/with}}", + {value: true, awesome: function(context, options) { return options.fn(context); }}, + "inner 1", "block functions are called with context and options"); + }); + it("block functions without context argument", function() { shouldCompileTo("{{#awesome}}inner{{/awesome}}", {awesome: function(options) { return options.fn(this); }}, "inner", "block functions are called with options"); }); + it("pathed block functions without context argument", function() { + shouldCompileTo("{{#foo.awesome}}inner{{/foo.awesome}}", + {foo: {awesome: function(options) { return this; }}}, + "inner", "block functions are called with options"); + }); + it("depthed block functions without context argument", function() { + shouldCompileTo("{{#with value}}{{#../awesome}}inner{{/../awesome}}{{/with}}", + {value: true, awesome: function(options) { return this; }}, + "inner", "block functions are called with options"); + }); it("paths with hyphens", function() { |