summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYehuda Katz <tomhuda@Yehudas-iMac.local>2011-12-27 15:57:08 -0800
committerYehuda Katz <tomhuda@Yehudas-iMac.local>2011-12-27 15:57:08 -0800
commite474e56b804d55d294d7bd1ae6c37c4bc57eb1f0 (patch)
tree923644846a198ec60e0973d8bc95bfba939bd0e0 /lib
parent69307d0e2b149228c1422ac30b6b2020b1a75ed9 (diff)
downloadhandlebars.js-e474e56b804d55d294d7bd1ae6c37c4bc57eb1f0.zip
handlebars.js-e474e56b804d55d294d7bd1ae6c37c4bc57eb1f0.tar.gz
handlebars.js-e474e56b804d55d294d7bd1ae6c37c4bc57eb1f0.tar.bz2
data should be passed through to partials. closes #111.
Diffstat (limited to 'lib')
-rw-r--r--lib/handlebars/compiler/compiler.js8
-rw-r--r--lib/handlebars/vm.js8
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index 427e0a5..4bc1f82 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -638,7 +638,13 @@ Handlebars.JavaScriptCompiler = function() {};
},
invokePartial: function(context) {
- this.pushStack("self.invokePartial(" + this.nameLookup('partials', context, 'partial') + ", '" + context + "', " + this.popStack() + ", helpers, partials);");
+ params = [this.nameLookup('partials', context, 'partial'), "'" + context + "'", this.popStack(), "helpers", "partials"];
+
+ if (this.options.data) {
+ params.push("data");
+ }
+
+ this.pushStack("self.invokePartial(" + params.join(", ") + ");");
},
assignToHash: function(key) {
diff --git a/lib/handlebars/vm.js b/lib/handlebars/vm.js
index 7f9a42e..ecb4ce3 100644
--- a/lib/handlebars/vm.js
+++ b/lib/handlebars/vm.js
@@ -46,16 +46,18 @@ Handlebars.VM = {
};
},
noop: function() { return ""; },
- invokePartial: function(partial, name, context, helpers, partials) {
+ invokePartial: function(partial, name, context, helpers, partials, data) {
+ options = { helpers: helpers, partials: partials, data: data };
+
if(partial === undefined) {
throw new Handlebars.Exception("The partial " + name + " could not be found");
} else if(partial instanceof Function) {
- return partial(context, {helpers: helpers, partials: partials});
+ return partial(context, options);
} else if (!Handlebars.compile) {
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in vm mode");
} else {
partials[name] = Handlebars.compile(partial);
- return partials[name](context, {helpers: helpers, partials: partials});
+ return partials[name](context, options);
}
}
};