summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/helpers.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-11-26 09:01:03 -0600
committerkpdecker <kpdecker@gmail.com>2014-11-26 09:01:03 -0600
commit61dd721ca2a9055036d0f350970d033ca5227411 (patch)
tree398a184db4673792629973a3b11d9a46aa108bb0 /lib/handlebars/compiler/helpers.js
parent3a9440f954092558275cd4c05a35ba34bcbfa210 (diff)
downloadhandlebars.js-61dd721ca2a9055036d0f350970d033ca5227411.zip
handlebars.js-61dd721ca2a9055036d0f350970d033ca5227411.tar.gz
handlebars.js-61dd721ca2a9055036d0f350970d033ca5227411.tar.bz2
Update AST location info to match SpiderMonkey
Part of #889
Diffstat (limited to 'lib/handlebars/compiler/helpers.js')
-rw-r--r--lib/handlebars/compiler/helpers.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/handlebars/compiler/helpers.js b/lib/handlebars/compiler/helpers.js
index 50a3c53..3a3ece6 100644
--- a/lib/handlebars/compiler/helpers.js
+++ b/lib/handlebars/compiler/helpers.js
@@ -1,5 +1,17 @@
import Exception from "../exception";
+export function SourceLocation(source, locInfo) {
+ this.source = source;
+ this.start = {
+ line: locInfo.first_line,
+ column: locInfo.first_column
+ };
+ this.end = {
+ line: locInfo.last_line,
+ column: locInfo.last_column
+ };
+}
+
export function stripFlags(open, close) {
return {
left: open.charAt(2) === '~',
@@ -15,10 +27,7 @@ export function stripComment(comment) {
export function prepareRawBlock(openRawBlock, content, close, locInfo) {
/*jshint -W040 */
if (openRawBlock.sexpr.id.original !== close) {
- var errorNode = {
- firstLine: openRawBlock.sexpr.firstLine,
- firstColumn: openRawBlock.sexpr.firstColumn
- };
+ var errorNode = {loc: openRawBlock.sexpr.loc};
throw new Exception(openRawBlock.sexpr.id.original + " doesn't match " + close, errorNode);
}
@@ -32,10 +41,7 @@ export function prepareBlock(openBlock, program, inverseAndProgram, close, inver
/*jshint -W040 */
// When we are chaining inverse calls, we will not have a close path
if (close && close.path && openBlock.sexpr.id.original !== close.path.original) {
- var errorNode = {
- firstLine: openBlock.sexpr.firstLine,
- firstColumn: openBlock.sexpr.firstColumn
- };
+ var errorNode = {loc: openBlock.sexpr.loc};
throw new Exception(openBlock.sexpr.id.original + ' doesn\'t match ' + close.path.original, errorNode);
}