diff options
author | kpdecker <kpdecker@gmail.com> | 2014-01-17 19:14:36 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-01-17 23:15:17 -0600 |
commit | ace2896ec876104f5bd220744124e7370fe6b9a2 (patch) | |
tree | 93fd30d6e64324e6914fb212310cfdedc3a6d260 /lib/handlebars/compiler/ast.js | |
parent | 9df919083d4e25512fb6dc6fe1a050e63ad12c80 (diff) | |
download | handlebars.js-ace2896ec876104f5bd220744124e7370fe6b9a2.zip handlebars.js-ace2896ec876104f5bd220744124e7370fe6b9a2.tar.gz handlebars.js-ace2896ec876104f5bd220744124e7370fe6b9a2.tar.bz2 |
Add trackIds compiler flag
Allows helpers that care about where a particular field came from derive this data while maintaining backward compatibility with existing helpers.
Diffstat (limited to 'lib/handlebars/compiler/ast.js')
-rw-r--r-- | lib/handlebars/compiler/ast.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js index 6789883..5a5f514 100644 --- a/lib/handlebars/compiler/ast.js +++ b/lib/handlebars/compiler/ast.js @@ -149,7 +149,8 @@ var AST = { var original = "", dig = [], - depth = 0; + depth = 0, + depthString = ''; for(var i=0,l=parts.length; i<l; i++) { var part = parts[i].part; @@ -160,6 +161,7 @@ var AST = { throw new Exception("Invalid path: " + original, this); } else if (part === "..") { depth++; + depthString += '../'; } else { this.isScoped = true; } @@ -172,6 +174,7 @@ var AST = { this.parts = dig; this.string = dig.join('.'); this.depth = depth; + this.idName = depthString + this.string; // an ID is simple if it only has one part, and that part is not // `..` or `this`. @@ -191,6 +194,7 @@ var AST = { this.type = "DATA"; this.id = id; this.stringModeValue = id.stringModeValue; + this.idName = '@' + id.stringModeValue; }, StringNode: function(string, locInfo) { |