diff options
author | kpdecker <kpdecker@gmail.com> | 2015-04-20 02:38:28 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2015-04-20 02:38:28 -0500 |
commit | 4bed826d0e210c336fb9e500835b1c1926562da5 (patch) | |
tree | afd32d4dc7b4c2fcf6c38d0355def38ddaffdcc0 /lib/handlebars/compiler/whitespace-control.js | |
parent | 0263aa48bc8c8cdcd332edd01a644a9a0fd1cc81 (diff) | |
download | handlebars.js-4bed826d0e210c336fb9e500835b1c1926562da5.zip handlebars.js-4bed826d0e210c336fb9e500835b1c1926562da5.tar.gz handlebars.js-4bed826d0e210c336fb9e500835b1c1926562da5.tar.bz2 |
Update for let and optional parameters
Diffstat (limited to 'lib/handlebars/compiler/whitespace-control.js')
-rw-r--r-- | lib/handlebars/compiler/whitespace-control.js | 30 |
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; |