Add support for complex ids in @data references
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user