summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/printer.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler/printer.js')
-rw-r--r--lib/handlebars/compiler/printer.js34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/handlebars/compiler/printer.js b/lib/handlebars/compiler/printer.js
index dcc73c3..5c708a1 100644
--- a/lib/handlebars/compiler/printer.js
+++ b/lib/handlebars/compiler/printer.js
@@ -1,4 +1,5 @@
-import Visitor from "./visitor";
+/*eslint-disable new-cap */
+import Visitor from './visitor';
export function print(ast) {
return new PrintVisitor().accept(ast);
@@ -11,13 +12,13 @@ export function PrintVisitor() {
PrintVisitor.prototype = new Visitor();
PrintVisitor.prototype.pad = function(string) {
- var out = "";
+ var out = '';
- for(var i=0,l=this.padding; i<l; i++) {
- out = out + " ";
+ for (var i = 0, l = this.padding; i < l; i++) {
+ out = out + ' ';
}
- out = out + string + "\n";
+ out = out + string + '\n';
return out;
};
@@ -28,14 +29,14 @@ PrintVisitor.prototype.Program = function(program) {
if (program.blockParams) {
var blockParams = 'BLOCK PARAMS: [';
- for(i=0, l=program.blockParams.length; i<l; i++) {
+ for (i = 0, l = program.blockParams.length; i < l; i++) {
blockParams += ' ' + program.blockParams[i];
}
blockParams += ' ]';
out += this.pad(blockParams);
}
- for(i=0, l=body.length; i<l; i++) {
+ for (i = 0, l = body.length; i < l; i++) {
out = out + this.accept(body[i]);
}
@@ -49,7 +50,7 @@ PrintVisitor.prototype.MustacheStatement = function(mustache) {
};
PrintVisitor.prototype.BlockStatement = function(block) {
- var out = "";
+ var out = '';
out = out + this.pad('BLOCK:');
this.padding++;
@@ -75,7 +76,7 @@ PrintVisitor.prototype.BlockStatement = function(block) {
PrintVisitor.prototype.PartialStatement = function(partial) {
var content = 'PARTIAL:' + partial.name.original;
- if(partial.params[0]) {
+ if (partial.params[0]) {
content += ' ' + this.accept(partial.params[0]);
}
if (partial.hash) {
@@ -95,15 +96,15 @@ PrintVisitor.prototype.CommentStatement = function(comment) {
PrintVisitor.prototype.SubExpression = function(sexpr) {
var params = sexpr.params, paramStrings = [], hash;
- for(var i=0, l=params.length; i<l; i++) {
+ for (var i = 0, l = params.length; i < l; i++) {
paramStrings.push(this.accept(params[i]));
}
- params = "[" + paramStrings.join(", ") + "]";
+ params = '[' + paramStrings.join(', ') + ']';
- hash = sexpr.hash ? " " + this.accept(sexpr.hash) : "";
+ hash = sexpr.hash ? ' ' + this.accept(sexpr.hash) : '';
- return this.accept(sexpr.path) + " " + params + hash;
+ return this.accept(sexpr.path) + ' ' + params + hash;
};
PrintVisitor.prototype.PathExpression = function(id) {
@@ -117,11 +118,11 @@ PrintVisitor.prototype.StringLiteral = function(string) {
};
PrintVisitor.prototype.NumberLiteral = function(number) {
- return "NUMBER{" + number.value + "}";
+ return 'NUMBER{' + number.value + '}';
};
PrintVisitor.prototype.BooleanLiteral = function(bool) {
- return "BOOLEAN{" + bool.value + "}";
+ return 'BOOLEAN{' + bool.value + '}';
};
PrintVisitor.prototype.UndefinedLiteral = function() {
@@ -136,7 +137,7 @@ PrintVisitor.prototype.Hash = function(hash) {
var pairs = hash.pairs;
var joinedPairs = [];
- for (var i=0, l=pairs.length; i<l; i++) {
+ for (var i = 0, l = pairs.length; i < l; i++) {
joinedPairs.push(this.accept(pairs[i]));
}
@@ -145,3 +146,4 @@ PrintVisitor.prototype.Hash = function(hash) {
PrintVisitor.prototype.HashPair = function(pair) {
return pair.key + '=' + this.accept(pair.value);
};
+/*eslint-enable new-cap */