Add support for complex ids in @data references

This commit is contained in:
kpdecker
2013-05-27 14:40:52 -05:00
parent 5f349913aa
commit 822a8911ec
9 changed files with 101 additions and 30 deletions
+10 -2
View File
@@ -301,7 +301,15 @@ Compiler.prototype = {
DATA: function(data) {
this.options.data = true;
this.opcode('lookupData', data.id);
if (data.id.isScoped || data.id.depth) {
throw new Handlebars.Exception('Scoped data references are not supported: ' + data.original);
}
this.opcode('lookupData');
var parts = data.id.parts;
for(var i=0, l=parts.length; i<l; i++) {
this.opcode('lookup', parts[i]);
}
},
STRING: function(string) {
@@ -749,7 +757,7 @@ JavaScriptCompiler.prototype = {
//
// Push the result of looking up `id` on the current data
lookupData: function(id) {
this.push(this.nameLookup('data', id, 'data'));
this.push('data');
},
// [pushStringParam]
+1 -1
View File
@@ -121,7 +121,7 @@ Handlebars.PrintVisitor.prototype.PARTIAL_NAME = function(partialName) {
};
Handlebars.PrintVisitor.prototype.DATA = function(data) {
return "@" + data.id;
return "@" + this.accept(data.id);
};
Handlebars.PrintVisitor.prototype.content = function(content) {