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.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/handlebars/compiler/helpers.js b/lib/handlebars/compiler/helpers.js
index fc0120c..e3eb786 100644
--- a/lib/handlebars/compiler/helpers.js
+++ b/lib/handlebars/compiler/helpers.js
@@ -121,3 +121,28 @@ export function prepareBlock(openBlock, program, inverseAndProgram, close, inver
openBlock.strip, inverseStrip, close && close.strip,
this.locInfo(locInfo));
}
+
+export function prepareProgram(statements, loc) {
+ if (!loc && statements.length) {
+ const first = statements[0].loc,
+ last = statements[statements.length - 1].loc;
+
+ if (first && last) {
+ loc = {
+ source: first.source,
+ start: {
+ line: first.start.line,
+ column: first.start.column
+ },
+ end: {
+ line: last.end.line,
+ column: last.end.column
+ }
+ };
+ }
+ }
+
+ return new this.Program(statements, null, {}, loc);
+}
+
+