summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/whitespace-control.js
diff options
context:
space:
mode:
authorKevin Decker <kpdecker@gmail.com>2015-04-16 17:12:40 -0500
committerKevin Decker <kpdecker@gmail.com>2015-04-16 17:12:40 -0500
commitc6ab044fa88d54ace17200b47213c80cdb24ead6 (patch)
tree2bbdad0c644ba83acc219702500390b874f3ac90 /lib/handlebars/compiler/whitespace-control.js
parent2a02261a5bc78f246c63dd8d467a12f2c1f63734 (diff)
parentfdc94207a32ad60336a60cdb97b08726d10cae39 (diff)
downloadhandlebars.js-c6ab044fa88d54ace17200b47213c80cdb24ead6.zip
handlebars.js-c6ab044fa88d54ace17200b47213c80cdb24ead6.tar.gz
handlebars.js-c6ab044fa88d54ace17200b47213c80cdb24ead6.tar.bz2
Merge pull request #998 from wycats/babel
Add full support for es6
Diffstat (limited to 'lib/handlebars/compiler/whitespace-control.js')
-rw-r--r--lib/handlebars/compiler/whitespace-control.js23
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;
}