summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler/helpers.js')
-rw-r--r--lib/handlebars/compiler/helpers.js72
1 files changed, 55 insertions, 17 deletions
diff --git a/lib/handlebars/compiler/helpers.js b/lib/handlebars/compiler/helpers.js
index f2edfa1..bf72034 100644
--- a/lib/handlebars/compiler/helpers.js
+++ b/lib/handlebars/compiler/helpers.js
@@ -32,8 +32,8 @@ export function stripComment(comment) {
.replace(/-?-?~?\}\}$/, '');
}
-export function preparePath(data, parts, locInfo) {
- locInfo = this.locInfo(locInfo);
+export function preparePath(data, parts, loc) {
+ loc = this.locInfo(loc);
let original = data ? '@' : '',
dig = [],
@@ -49,7 +49,7 @@ export function preparePath(data, parts, locInfo) {
if (!isLiteral && (part === '..' || part === '.' || part === 'this')) {
if (dig.length > 0) {
- throw new Exception('Invalid path: ' + original, {loc: locInfo});
+ throw new Exception('Invalid path: ' + original, {loc});
} else if (part === '..') {
depth++;
depthString += '../';
@@ -59,7 +59,14 @@ export function preparePath(data, parts, locInfo) {
}
}
- return new this.PathExpression(data, depth, dig, original, locInfo);
+ return {
+ type: 'PathExpression',
+ data,
+ depth,
+ parts: dig,
+ original,
+ loc
+ };
}
export function prepareMustache(path, params, hash, open, strip, locInfo) {
@@ -67,7 +74,15 @@ export function prepareMustache(path, params, hash, open, strip, locInfo) {
let escapeFlag = open.charAt(3) || open.charAt(2),
escaped = escapeFlag !== '{' && escapeFlag !== '&';
- return new this.MustacheStatement(path, params, hash, escaped, strip, this.locInfo(locInfo));
+ return {
+ type: 'MustacheStatement',
+ path,
+ params,
+ hash,
+ escaped,
+ strip,
+ loc: this.locInfo(locInfo)
+ };
}
export function prepareRawBlock(openRawBlock, contents, close, locInfo) {
@@ -78,13 +93,24 @@ export function prepareRawBlock(openRawBlock, contents, close, locInfo) {
}
locInfo = this.locInfo(locInfo);
- let program = new this.Program(contents, null, {}, locInfo);
+ let program = {
+ type: 'Program',
+ body: contents,
+ strip: {},
+ loc: locInfo
+ };
- return new this.BlockStatement(
- openRawBlock.path, openRawBlock.params, openRawBlock.hash,
- program, undefined,
- {}, {}, {},
- locInfo);
+ return {
+ type: 'BlockStatement',
+ path: openRawBlock.path,
+ params: openRawBlock.params,
+ hash: openRawBlock.hash,
+ program,
+ openStrip: {},
+ inverseStrip: {},
+ closeStrip: {},
+ loc: locInfo
+ };
}
export function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) {
@@ -115,11 +141,18 @@ export function prepareBlock(openBlock, program, inverseAndProgram, close, inver
program = inverted;
}
- return new this.BlockStatement(
- openBlock.path, openBlock.params, openBlock.hash,
- program, inverse,
- openBlock.strip, inverseStrip, close && close.strip,
- this.locInfo(locInfo));
+ return {
+ type: 'BlockStatement',
+ path: openBlock.path,
+ params: openBlock.params,
+ hash: openBlock.hash,
+ program,
+ inverse,
+ openStrip: openBlock.strip,
+ inverseStrip,
+ closeStrip: close && close.strip,
+ loc: this.locInfo(locInfo)
+ };
}
export function prepareProgram(statements, loc) {
@@ -143,7 +176,12 @@ export function prepareProgram(statements, loc) {
}
}
- return new this.Program(statements, null, {}, loc);
+ return {
+ type: 'Program',
+ body: statements,
+ strip: {},
+ loc: loc
+ };
}