diff options
author | Peter Wagenet <peter.wagenet@gmail.com> | 2012-02-08 19:42:39 -0800 |
---|---|---|
committer | Peter Wagenet <peter.wagenet@gmail.com> | 2012-02-08 20:49:49 -0800 |
commit | 2ea95ca08d47bb16ed79e8481c50a1c074dd676e (patch) | |
tree | 3d6000f7df428c34c3ee5b066caac252e25fca10 | |
parent | cb9db98642ef2083e0be1048a0b54ac210c4fcfd (diff) | |
download | handlebars.js-2ea95ca08d47bb16ed79e8481c50a1c074dd676e.zip handlebars.js-2ea95ca08d47bb16ed79e8481c50a1c074dd676e.tar.gz handlebars.js-2ea95ca08d47bb16ed79e8481c50a1c074dd676e.tar.bz2 |
Fixed whitespace and semi-colons
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 28 | ||||
-rw-r--r-- | lib/handlebars/utils.js | 2 | ||||
-rw-r--r-- | src/handlebars.yy | 74 |
3 files changed, 52 insertions, 52 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index a630200..336b60d 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -316,13 +316,13 @@ Handlebars.JavaScriptCompiler = function() {}; // PUBLIC API: You can override these methods in a subclass to provide // alternative compiled forms for name lookup and buffering semantics nameLookup: function(parent, name, type) { - if (/^[0-9]+$/.test(name)) { + if (/^[0-9]+$/.test(name)) { return parent + "[" + name + "]"; } else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) { - return parent + "." + name; - } - else { - return parent + "['" + name + "']"; + return parent + "." + name; + } + else { + return parent + "['" + name + "']"; } }, @@ -447,7 +447,7 @@ Handlebars.JavaScriptCompiler = function() {}; // Generate minimizer alias mappings if (!this.isChild) { - var aliases = [] + var aliases = []; for (var alias in this.context.aliases) { this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias]; } @@ -540,7 +540,7 @@ Handlebars.JavaScriptCompiler = function() {}; lookup: function(name) { var topStack = this.topStack(); this.source.push(topStack + " = (" + topStack + " === null || " + topStack + " === undefined || " + topStack + " === false ? " + - topStack + " : " + this.nameLookup(topStack, name, 'context') + ");"); + topStack + " : " + this.nameLookup(topStack, name, 'context') + ");"); }, pushStringParam: function(string) { @@ -635,7 +635,7 @@ Handlebars.JavaScriptCompiler = function() {}; this.source.push(nextStack + " = " + id + ".call(" + paramString + ");"); } else { this.context.aliases.functionType = '"function"'; - var condition = program ? "foundHelper && " : "" + var condition = program ? "foundHelper && " : ""; this.source.push("if(" + condition + "typeof " + id + " === functionType) { " + nextStack + " = " + id + ".call(" + paramString + "); }"); } fn.call(this, nextStack, helperMissingString, id); @@ -764,12 +764,12 @@ Handlebars.JavaScriptCompiler = function() {}; compilerWords[reservedWords[i]] = true; } - JavaScriptCompiler.isValidJavaScriptVariableName = function(name) { - if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) { - return true; - } - return false; - } + JavaScriptCompiler.isValidJavaScriptVariableName = function(name) { + if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) { + return true; + } + return false; + }; })(Handlebars.Compiler, Handlebars.JavaScriptCompiler); diff --git a/lib/handlebars/utils.js b/lib/handlebars/utils.js index 5c7c2a3..bd5d0eb 100644 --- a/lib/handlebars/utils.js +++ b/lib/handlebars/utils.js @@ -10,7 +10,7 @@ Handlebars.Exception = function(message) { this.message = tmp.message; }; -Handlebars.Exception.prototype = new Error; +Handlebars.Exception.prototype = new Error(); // Build out our basic SafeString type Handlebars.SafeString = function(string) { diff --git a/src/handlebars.yy b/src/handlebars.yy index d3d41df..a48e834 100644 --- a/src/handlebars.yy +++ b/src/handlebars.yy @@ -3,50 +3,50 @@ %% root - : program EOF { return $1 } + : program EOF { return $1; } ; program - : statements simpleInverse statements { $$ = new yy.ProgramNode($1, $3) } - | statements { $$ = new yy.ProgramNode($1) } - | "" { $$ = new yy.ProgramNode([]) } + : statements simpleInverse statements { $$ = new yy.ProgramNode($1, $3); } + | statements { $$ = new yy.ProgramNode($1); } + | "" { $$ = new yy.ProgramNode([]); } ; statements - : statement { $$ = [$1] } - | statements statement { $1.push($2); $$ = $1 } + : statement { $$ = [$1]; } + | statements statement { $1.push($2); $$ = $1; } ; statement - : openInverse program closeBlock { $$ = new yy.InverseNode($1, $2, $3) } - | openBlock program closeBlock { $$ = new yy.BlockNode($1, $2, $3) } - | mustache { $$ = $1 } - | partial { $$ = $1 } - | CONTENT { $$ = new yy.ContentNode($1) } - | COMMENT { $$ = new yy.CommentNode($1) } + : openInverse program closeBlock { $$ = new yy.InverseNode($1, $2, $3); } + | openBlock program closeBlock { $$ = new yy.BlockNode($1, $2, $3); } + | mustache { $$ = $1; } + | partial { $$ = $1; } + | CONTENT { $$ = new yy.ContentNode($1); } + | COMMENT { $$ = new yy.CommentNode($1); } ; openBlock - : OPEN_BLOCK inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1]) } + : OPEN_BLOCK inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1]); } ; openInverse - : OPEN_INVERSE inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1]) } + : OPEN_INVERSE inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1]); } ; closeBlock - : OPEN_ENDBLOCK path CLOSE { $$ = $2 } + : OPEN_ENDBLOCK path CLOSE { $$ = $2; } ; mustache - : OPEN inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1]) } - | OPEN_UNESCAPED inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1], true) } + : OPEN inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1]); } + | OPEN_UNESCAPED inMustache CLOSE { $$ = new yy.MustacheNode($2[0], $2[1], true); } ; partial - : OPEN_PARTIAL path CLOSE { $$ = new yy.PartialNode($2) } - | OPEN_PARTIAL path path CLOSE { $$ = new yy.PartialNode($2, $3) } + : OPEN_PARTIAL path CLOSE { $$ = new yy.PartialNode($2); } + | OPEN_PARTIAL path path CLOSE { $$ = new yy.PartialNode($2, $3); } ; simpleInverse @@ -54,46 +54,46 @@ simpleInverse ; inMustache - : path params hash { $$ = [[$1].concat($2), $3] } - | path params { $$ = [[$1].concat($2), null] } - | path hash { $$ = [[$1], $2] } - | path { $$ = [[$1], null] } + : path params hash { $$ = [[$1].concat($2), $3]; } + | path params { $$ = [[$1].concat($2), null]; } + | path hash { $$ = [[$1], $2]; } + | path { $$ = [[$1], null]; } ; params : params param { $1.push($2); $$ = $1; } - | param { $$ = [$1] } + | param { $$ = [$1]; } ; param - : path { $$ = $1 } - | STRING { $$ = new yy.StringNode($1) } - | INTEGER { $$ = new yy.IntegerNode($1) } - | BOOLEAN { $$ = new yy.BooleanNode($1) } + : path { $$ = $1; } + | STRING { $$ = new yy.StringNode($1); } + | INTEGER { $$ = new yy.IntegerNode($1); } + | BOOLEAN { $$ = new yy.BooleanNode($1); } ; hash - : hashSegments { $$ = new yy.HashNode($1) } + : hashSegments { $$ = new yy.HashNode($1); } ; hashSegments - : hashSegments hashSegment { $1.push($2); $$ = $1 } - | hashSegment { $$ = [$1] } + : hashSegments hashSegment { $1.push($2); $$ = $1; } + | hashSegment { $$ = [$1]; } ; hashSegment - : ID EQUALS path { $$ = [$1, $3] } - | ID EQUALS STRING { $$ = [$1, new yy.StringNode($3)] } - | ID EQUALS INTEGER { $$ = [$1, new yy.IntegerNode($3)] } - | ID EQUALS BOOLEAN { $$ = [$1, new yy.BooleanNode($3)] } + : ID EQUALS path { $$ = [$1, $3]; } + | ID EQUALS STRING { $$ = [$1, new yy.StringNode($3)]; } + | ID EQUALS INTEGER { $$ = [$1, new yy.IntegerNode($3)]; } + | ID EQUALS BOOLEAN { $$ = [$1, new yy.BooleanNode($3)]; } ; path - : pathSegments { $$ = new yy.IdNode($1) } + : pathSegments { $$ = new yy.IdNode($1); } ; pathSegments : pathSegments SEP ID { $1.push($3); $$ = $1; } - | ID { $$ = [$1] } + | ID { $$ = [$1]; } ; |