diff options
author | kpdecker <kpdecker@gmail.com> | 2015-04-16 15:42:46 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2015-04-16 16:43:01 -0500 |
commit | e3d3eda2e1e03e997d417affc09974446b4ca701 (patch) | |
tree | a6513f267482b1693fd002c20488c6e92095ff2b /lib/handlebars/compiler/whitespace-control.js | |
parent | 2a02261a5bc78f246c63dd8d467a12f2c1f63734 (diff) | |
download | handlebars.js-e3d3eda2e1e03e997d417affc09974446b4ca701.zip handlebars.js-e3d3eda2e1e03e997d417affc09974446b4ca701.tar.gz handlebars.js-e3d3eda2e1e03e997d417affc09974446b4ca701.tar.bz2 |
Add full support for es6
Converts the tool chain to use babel, eslint, and webpack vs. the previous proprietary solutions.
Additionally begins enforcing additional linting concerns as well as updates the code to reflect these rules.
Fixes #855
Fixes #993
Diffstat (limited to 'lib/handlebars/compiler/whitespace-control.js')
-rw-r--r-- | lib/handlebars/compiler/whitespace-control.js | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/handlebars/compiler/whitespace-control.js b/lib/handlebars/compiler/whitespace-control.js index 9786612..aabe45a 100644 --- a/lib/handlebars/compiler/whitespace-control.js +++ b/lib/handlebars/compiler/whitespace-control.js @@ -1,4 +1,4 @@ -import Visitor from "./visitor"; +import Visitor from './visitor'; function WhitespaceControl() { } @@ -38,7 +38,7 @@ WhitespaceControl.prototype.Program = function(program) { // If we are on a standalone node, save the indent info for partials if (current.type === 'PartialStatement') { // Pull out the whitespace from the final line - current.indent = (/([ \t]+$)/).exec(body[i-1].original)[1]; + current.indent = (/([ \t]+$)/).exec(body[i - 1].original)[1]; } } } @@ -73,7 +73,7 @@ WhitespaceControl.prototype.BlockStatement = function(block) { // Walk the inverse chain to find the last inverse that is actually in the chain. while (lastInverse.chained) { - lastInverse = lastInverse.body[lastInverse.body.length-1].program; + lastInverse = lastInverse.body[lastInverse.body.length - 1].program; } } @@ -108,14 +108,11 @@ WhitespaceControl.prototype.BlockStatement = function(block) { // Find standalone else statments if (isPrevWhitespace(program.body) && isNextWhitespace(firstInverse.body)) { - omitLeft(program.body); omitRight(firstInverse.body); } - } else { - if (block.closeStrip.open) { - omitLeft(program.body, null, true); - } + } else if (block.closeStrip.open) { + omitLeft(program.body, null, true); } return strip; @@ -125,7 +122,7 @@ WhitespaceControl.prototype.MustacheStatement = function(mustache) { return mustache.strip; }; -WhitespaceControl.prototype.PartialStatement = +WhitespaceControl.prototype.PartialStatement = WhitespaceControl.prototype.CommentStatement = function(node) { /* istanbul ignore next */ var strip = node.strip || {}; @@ -144,8 +141,8 @@ 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], - sibling = body[i-2]; + var prev = body[i - 1], + sibling = body[i - 2]; if (!prev) { return isRoot; } @@ -159,8 +156,8 @@ function isNextWhitespace(body, i, isRoot) { i = -1; } - var next = body[i+1], - sibling = body[i+2]; + var next = body[i + 1], + sibling = body[i + 2]; if (!next) { return isRoot; } |