summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2012-07-05 23:05:55 -0700
committerYehuda Katz <wycats@gmail.com>2012-07-05 23:05:55 -0700
commit46c04fa71e1aa960c874a14b9596425aa04a2297 (patch)
tree849796f08e2b83c64ea99cd46168cf9ada4ce700 /lib/handlebars/compiler/compiler.js
parent5e8be14d78f87e73878e4d29013482f7daff9d8a (diff)
downloadhandlebars.js-46c04fa71e1aa960c874a14b9596425aa04a2297.zip
handlebars.js-46c04fa71e1aa960c874a14b9596425aa04a2297.tar.gz
handlebars.js-46c04fa71e1aa960c874a14b9596425aa04a2297.tar.bz2
Make deep @data trigger the data option
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r--lib/handlebars/compiler/compiler.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index ae48c69..c7d2dbb 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -216,7 +216,7 @@ Handlebars.JavaScriptCompiler = function() {};
}
if (id.type === 'DATA') {
- this.opcode('lookupData', id.id);
+ this.DATA(id);
} else if (id.parts.length) {
this.opcode('lookupOnContext', id.parts[0]);
for(var i=1, l=id.parts.length; i<l; i++) {
@@ -252,6 +252,7 @@ Handlebars.JavaScriptCompiler = function() {};
},
DATA: function(data) {
+ this.options.data = true;
this.opcode('lookupData', data.id);
},
@@ -446,7 +447,8 @@ Handlebars.JavaScriptCompiler = function() {};
if (!this.isChild) {
var namespace = this.namespace;
var copies = "helpers = helpers || " + namespace + ".helpers;";
- if(this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
+ if (this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
+ if (this.options.data) { copies = copies + " data = data || {};"; }
out.push(copies);
} else {
out.push('');