diff options
author | kpdecker <kpdecker@gmail.com> | 2014-11-26 20:35:33 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-11-26 20:36:36 -0600 |
commit | 5c921cafebee438fa27d417ae701b24323373a30 (patch) | |
tree | b83b875444816351d3e45f13e8ddf3769294cad1 /lib/handlebars/compiler/ast.js | |
parent | 697bbe59cad06bc74a945f7e26fc0af333a01d47 (diff) | |
download | handlebars.js-5c921cafebee438fa27d417ae701b24323373a30.zip handlebars.js-5c921cafebee438fa27d417ae701b24323373a30.tar.gz handlebars.js-5c921cafebee438fa27d417ae701b24323373a30.tar.bz2 |
Replace DataNode and IdNode with PathNode
This is a breaking change for string mode users as there is no longer a distinct type for data parameters. Instead data consumers should look for the @ prefix value.
Diffstat (limited to 'lib/handlebars/compiler/ast.js')
-rw-r--r-- | lib/handlebars/compiler/ast.js | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js index 44b26ec..287a9e5 100644 --- a/lib/handlebars/compiler/ast.js +++ b/lib/handlebars/compiler/ast.js @@ -92,11 +92,11 @@ var AST = { this.pairs = pairs; }, - IdNode: function(parts, locInfo) { + PathNode: function(data, parts, locInfo) { this.loc = locInfo; - this.type = "ID"; + this.type = 'PathExpression'; - var original = "", + var original = '', dig = [], depth = 0, depthString = ''; @@ -105,10 +105,10 @@ var AST = { var part = parts[i].part; original += (parts[i].separator || '') + part; - if (part === ".." || part === "." || part === "this") { + if (part === '..' || part === '.' || part === 'this') { if (dig.length > 0) { - throw new Exception("Invalid path: " + original, this); - } else if (part === "..") { + throw new Exception('Invalid path: ' + original, this); + } else if (part === '..') { depth++; depthString += '../'; } else { @@ -119,25 +119,14 @@ var AST = { } } - this.original = original; + this.data = data; + this.original = (data ? '@' : '') + original; 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`. this.isSimple = parts.length === 1 && !this.isScoped && depth === 0; - - this.stringModeValue = this.string; - }, - - DataNode: function(id, locInfo) { - this.loc = locInfo; - this.type = "DATA"; - this.id = id; - this.stringModeValue = id.stringModeValue; - this.idName = '@' + id.stringModeValue; }, StringNode: function(string, locInfo) { |