summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/ast.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-01-01 19:14:51 -0600
committerkpdecker <kpdecker@gmail.com>2014-01-01 19:14:51 -0600
commit6e4e1f84040d8c7ee415ef711be7572ec94f3eb6 (patch)
tree90445963d0a48378bc200158d8d85fd4ce124dad /lib/handlebars/compiler/ast.js
parent3c85720137c039cefc38046541f05731d151a506 (diff)
downloadhandlebars.js-6e4e1f84040d8c7ee415ef711be7572ec94f3eb6.zip
handlebars.js-6e4e1f84040d8c7ee415ef711be7572ec94f3eb6.tar.gz
handlebars.js-6e4e1f84040d8c7ee415ef711be7572ec94f3eb6.tar.bz2
Include line info in compiler thrown exceptions
Fixes #636
Diffstat (limited to 'lib/handlebars/compiler/ast.js')
-rw-r--r--lib/handlebars/compiler/ast.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js
index 09bf927..002fd3b 100644
--- a/lib/handlebars/compiler/ast.js
+++ b/lib/handlebars/compiler/ast.js
@@ -106,12 +106,12 @@ var AST = {
},
BlockNode: function(mustache, program, inverse, close, locInfo) {
+ LocationInfo.call(this, locInfo);
+
if(mustache.sexpr.id.original !== close.path.original) {
- throw new Exception(mustache.sexpr.id.original + " doesn't match " + close.path.original);
+ throw new Exception(mustache.sexpr.id.original + " doesn't match " + close.path.original, this);
}
- LocationInfo.call(this, locInfo);
-
this.type = 'block';
this.mustache = mustache;
this.program = program;
@@ -155,11 +155,16 @@ var AST = {
original += (parts[i].separator || '') + part;
if (part === ".." || part === "." || part === "this") {
- if (dig.length > 0) { throw new Exception("Invalid path: " + original); }
- else if (part === "..") { depth++; }
- else { this.isScoped = true; }
+ if (dig.length > 0) {
+ throw new Exception("Invalid path: " + original, this);
+ } else if (part === "..") {
+ depth++;
+ } else {
+ this.isScoped = true;
+ }
+ } else {
+ dig.push(part);
}
- else { dig.push(part); }
}
this.original = original;