summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
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('');