diff options
Diffstat (limited to 'lib/handlebars/compiler')
-rw-r--r-- | lib/handlebars/compiler/code-gen.js | 13 | ||||
-rw-r--r-- | lib/handlebars/compiler/helpers.js | 17 |
2 files changed, 16 insertions, 14 deletions
diff --git a/lib/handlebars/compiler/code-gen.js b/lib/handlebars/compiler/code-gen.js index bc7bc07..3af4f8c 100644 --- a/lib/handlebars/compiler/code-gen.js +++ b/lib/handlebars/compiler/code-gen.js @@ -90,7 +90,8 @@ CodeGen.prototype = { } }, - empty: function(loc = this.currentLocation || {start: {}}) { + empty: function() { + let loc = this.currentLocation || {start: {}}; return new SourceNode(loc.start.line, loc.start.column, this.srcFile); }, wrap: function(chunk, loc = this.currentLocation || {start: {}}) { @@ -137,22 +138,22 @@ CodeGen.prototype = { }, - generateList: function(entries, loc) { - let ret = this.empty(loc); + generateList: function(entries) { + let ret = this.empty(); for (let i = 0, len = entries.length; i < len; i++) { if (i) { ret.add(','); } - ret.add(castChunk(entries[i], this, loc)); + ret.add(castChunk(entries[i], this)); } return ret; }, - generateArray: function(entries, loc) { - let ret = this.generateList(entries, loc); + generateArray: function(entries) { + let ret = this.generateList(entries); ret.prepend('['); ret.add(']'); diff --git a/lib/handlebars/compiler/helpers.js b/lib/handlebars/compiler/helpers.js index 1c8ab0d..f2edfa1 100644 --- a/lib/handlebars/compiler/helpers.js +++ b/lib/handlebars/compiler/helpers.js @@ -124,19 +124,20 @@ export function prepareBlock(openBlock, program, inverseAndProgram, close, inver export function prepareProgram(statements, loc) { if (!loc && statements.length) { - const first = statements[0].loc, - last = statements[statements.length - 1].loc; + const firstLoc = statements[0].loc, + lastLoc = statements[statements.length - 1].loc; - if (first && last) { + /* istanbul ignore else */ + if (firstLoc && lastLoc) { loc = { - source: first.source, + source: firstLoc.source, start: { - line: first.start.line, - column: first.start.column + line: firstLoc.start.line, + column: firstLoc.start.column }, end: { - line: last.end.line, - column: last.end.column + line: lastLoc.end.line, + column: lastLoc.end.column } }; } |