Fixed whitespace and semi-colons

This commit is contained in:
Peter Wagenet
2012-02-08 19:42:39 -08:00
parent cb9db98642
commit 2ea95ca08d
3 changed files with 52 additions and 52 deletions
+14 -14
View File
@@ -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);
+1 -1
View File
@@ -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) {
+37 -37
View File
@@ -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]; }
;