summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/whitespace-control.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler/whitespace-control.js')
-rw-r--r--lib/handlebars/compiler/whitespace-control.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/handlebars/compiler/whitespace-control.js b/lib/handlebars/compiler/whitespace-control.js
index aabe45a..5b76944 100644
--- a/lib/handlebars/compiler/whitespace-control.js
+++ b/lib/handlebars/compiler/whitespace-control.js
@@ -5,19 +5,19 @@ function WhitespaceControl() {
WhitespaceControl.prototype = new Visitor();
WhitespaceControl.prototype.Program = function(program) {
- var isRoot = !this.isRootSeen;
+ let isRoot = !this.isRootSeen;
this.isRootSeen = true;
- var body = program.body;
- for (var i = 0, l = body.length; i < l; i++) {
- var current = body[i],
+ let body = program.body;
+ for (let i = 0, l = body.length; i < l; i++) {
+ let current = body[i],
strip = this.accept(current);
if (!strip) {
continue;
}
- var _isPrevWhitespace = isPrevWhitespace(body, i, isRoot),
+ let _isPrevWhitespace = isPrevWhitespace(body, i, isRoot),
_isNextWhitespace = isNextWhitespace(body, i, isRoot),
openStandalone = strip.openStandalone && _isPrevWhitespace,
@@ -63,7 +63,7 @@ WhitespaceControl.prototype.BlockStatement = function(block) {
this.accept(block.inverse);
// Find the inverse program that is involed with whitespace stripping.
- var program = block.program || block.inverse,
+ let program = block.program || block.inverse,
inverse = block.program && block.inverse,
firstInverse = inverse,
lastInverse = inverse;
@@ -77,7 +77,7 @@ WhitespaceControl.prototype.BlockStatement = function(block) {
}
}
- var strip = {
+ let strip = {
open: block.openStrip.open,
close: block.closeStrip.close,
@@ -92,7 +92,7 @@ WhitespaceControl.prototype.BlockStatement = function(block) {
}
if (inverse) {
- var inverseStrip = block.inverseStrip;
+ let inverseStrip = block.inverseStrip;
if (inverseStrip.open) {
omitLeft(program.body, null, true);
@@ -125,7 +125,7 @@ WhitespaceControl.prototype.MustacheStatement = function(mustache) {
WhitespaceControl.prototype.PartialStatement =
WhitespaceControl.prototype.CommentStatement = function(node) {
/* istanbul ignore next */
- var strip = node.strip || {};
+ let strip = node.strip || {};
return {
inlineStandalone: true,
open: strip.open,
@@ -141,7 +141,7 @@ function isPrevWhitespace(body, i, isRoot) {
// Nodes that end with newlines are considered whitespace (but are special
// cased for strip operations)
- var prev = body[i - 1],
+ let prev = body[i - 1],
sibling = body[i - 2];
if (!prev) {
return isRoot;
@@ -156,7 +156,7 @@ function isNextWhitespace(body, i, isRoot) {
i = -1;
}
- var next = body[i + 1],
+ let next = body[i + 1],
sibling = body[i + 2];
if (!next) {
return isRoot;
@@ -175,12 +175,12 @@ function isNextWhitespace(body, i, isRoot) {
// If mulitple is truthy then all whitespace will be stripped out until non-whitespace
// content is met.
function omitRight(body, i, multiple) {
- var current = body[i == null ? 0 : i + 1];
+ let current = body[i == null ? 0 : i + 1];
if (!current || current.type !== 'ContentStatement' || (!multiple && current.rightStripped)) {
return;
}
- var original = current.value;
+ let original = current.value;
current.value = current.value.replace(multiple ? (/^\s+/) : (/^[ \t]*\r?\n?/), '');
current.rightStripped = current.value !== original;
}
@@ -193,13 +193,13 @@ function omitRight(body, i, multiple) {
// If mulitple is truthy then all whitespace will be stripped out until non-whitespace
// content is met.
function omitLeft(body, i, multiple) {
- var current = body[i == null ? body.length - 1 : i - 1];
+ let current = body[i == null ? body.length - 1 : i - 1];
if (!current || current.type !== 'ContentStatement' || (!multiple && current.leftStripped)) {
return;
}
// We omit the last node if it's whitespace only and not preceeded by a non-content node.
- var original = current.value;
+ let original = current.value;
current.value = current.value.replace(multiple ? (/\s+$/) : (/[ \t]+$/), '');
current.leftStripped = current.value !== original;
return current.leftStripped;