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.js44
1 files changed, 15 insertions, 29 deletions
diff --git a/lib/handlebars/compiler/printer.js b/lib/handlebars/compiler/printer.js
index b7485b7..8157190 100644
--- a/lib/handlebars/compiler/printer.js
+++ b/lib/handlebars/compiler/printer.js
@@ -18,31 +18,17 @@ Handlebars.PrintVisitor.prototype.pad = function(string, newline) {
};
Handlebars.PrintVisitor.prototype.program = function(program) {
- var out = this.pad("PROGRAM:"),
+ var out = "",
statements = program.statements,
inverse = program.inverse,
i, l;
- this.padding++;
-
for(i=0, l=statements.length; i<l; i++) {
out = out + this.accept(statements[i]);
}
this.padding--;
- if(inverse) {
- out = out + this.pad("{{^}}");
-
- this.padding++;
-
- for(i=0, l=inverse.statements.length; i<l; i++) {
- out = out + this.accept(inverse.statements[i]);
- }
- }
-
- this.padding--;
-
return out;
};
@@ -52,25 +38,25 @@ Handlebars.PrintVisitor.prototype.block = function(block) {
out = out + this.pad("BLOCK:");
this.padding++;
out = out + this.accept(block.mustache);
- out = out + this.accept(block.program);
- this.padding--;
-
- return out;
-};
-
-Handlebars.PrintVisitor.prototype.inverse = function(block) {
- var out = "";
-
- out = out + this.pad("INVERSE:");
- this.padding++;
- out = out + this.accept(block.mustache);
- out = out + this.accept(block.program);
+ if (block.program) {
+ out = out + this.pad("PROGRAM:");
+ this.padding++;
+ out = out + this.accept(block.program);
+ this.padding--;
+ }
+ if (block.inverse) {
+ if (block.program) { this.padding++; }
+ out = out + this.pad("{{^}}");
+ this.padding++;
+ out = out + this.accept(block.inverse);
+ this.padding--;
+ if (block.program) { this.padding--; }
+ }
this.padding--;
return out;
};
-
Handlebars.PrintVisitor.prototype.mustache = function(mustache) {
var params = mustache.params, paramStrings = [], hash;