Fix missing parameters for pathed mustaches

Fixes #658
This commit is contained in:
kpdecker
2014-01-17 22:56:40 -06:00
parent d4cfe90959
commit 33921beaa0
4 changed files with 37 additions and 7 deletions
+28
View File
@@ -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() {