linting
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
var Handlebars = {};
|
||||
Handlebars.Lexer = require("handlebars/jison_ext").Lexer
|
||||
Handlebars.Lexer = require("handlebars/jison_ext").Lexer;
|
||||
|
||||
// BEGIN(BROWSER)
|
||||
Handlebars.HandlebarsLexer = function() {
|
||||
this.state = "CONTENT";
|
||||
};
|
||||
Handlebars.HandlebarsLexer.prototype = new Handlebars.Lexer;
|
||||
Handlebars.HandlebarsLexer.prototype = new Handlebars.Lexer();
|
||||
|
||||
// The HandlebarsLexer uses a Lexer interface that is compatible
|
||||
// with Jison.
|
||||
@@ -22,14 +22,15 @@ Handlebars.HandlebarsLexer.prototype = new Handlebars.Lexer;
|
||||
// pointer in the case of parse errors is in
|
||||
// the right place.
|
||||
Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
if(this.input === "") return;
|
||||
if(this.input === "") { return; }
|
||||
|
||||
this.setupLex();
|
||||
|
||||
var lookahead = this.peek(2);
|
||||
var result = '';
|
||||
var peek;
|
||||
|
||||
if(lookahead === "") return;
|
||||
if(lookahead === "") { return; }
|
||||
|
||||
if(this.state == "MUSTACHE") {
|
||||
if(this.peek() === "/") {
|
||||
@@ -40,20 +41,20 @@ Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
// chomp optional whitespace
|
||||
while(this.peek() === " ") { this.ignorechar(); }
|
||||
|
||||
var lookahead = this.peek(2);
|
||||
lookahead = this.peek(2);
|
||||
|
||||
// in a mustache, but less than 2 characters left => error
|
||||
if(lookahead.length != 2) { return; }
|
||||
|
||||
// if the next characters are '}}', the mustache is done
|
||||
if(lookahead === "}}") {
|
||||
this.state = "CONTENT"
|
||||
this.state = "CONTENT";
|
||||
this.getchar(2);
|
||||
|
||||
// handle the case of {{{ foo }}} by always chomping
|
||||
// a final }. TODO: Track escape state and handle the
|
||||
// error condition here
|
||||
if(this.peek() == "}") this.getchar();
|
||||
if(this.peek() == "}") { this.getchar(); }
|
||||
return "CLOSE";
|
||||
|
||||
// if the next character is a quote => enter a String
|
||||
@@ -61,25 +62,25 @@ Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
this.readchar();
|
||||
|
||||
// scan the String until another quote is reached, skipping over escaped quotes
|
||||
while(this.peek() !== '"') { if(this.peek(2) === '\\"') { this.readchar() }; this.getchar() }
|
||||
while(this.peek() !== '"') { if(this.peek(2) === '\\"') { this.readchar(); } this.getchar(); }
|
||||
this.readchar();
|
||||
return "STRING";
|
||||
|
||||
// All other cases are IDs or errors
|
||||
} else {
|
||||
// grab alphanumeric characters
|
||||
while(this.peek().match(/[_0-9A-Za-z\.]/)) { this.getchar() }
|
||||
while(this.peek().match(/[_0-9A-Za-z\.]/)) { this.getchar(); }
|
||||
|
||||
var peek = this.peek();
|
||||
peek = this.peek();
|
||||
if(peek !== "}" && peek !== " " && peek !== "/") {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
// if any characters were grabbed => ID
|
||||
if(this.yytext.length) { return "ID" }
|
||||
if(this.yytext.length) { return "ID"; }
|
||||
|
||||
// Otherwise => Error
|
||||
else return;
|
||||
else { return; }
|
||||
}
|
||||
|
||||
// Next chars are {{ => Open mustache
|
||||
@@ -87,7 +88,7 @@ Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
this.state = "MUSTACHE";
|
||||
this.getchar(2);
|
||||
|
||||
var peek = this.peek();
|
||||
peek = this.peek();
|
||||
|
||||
if(peek === ">") {
|
||||
this.getchar();
|
||||
@@ -107,9 +108,9 @@ Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
} else if(peek === "!") {
|
||||
this.readchar();
|
||||
this.setupLex(); // reset the lexer state so the yytext is the comment only
|
||||
while(this.peek(2) !== "}}") { this.getchar(); };
|
||||
while(this.peek(2) !== "}}") { this.getchar(); }
|
||||
this.readchar(2);
|
||||
this.state = "CONTENT"
|
||||
this.state = "CONTENT";
|
||||
return "COMMENT";
|
||||
} else {
|
||||
return "OPEN";
|
||||
@@ -118,7 +119,7 @@ Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
// Otherwise => content section
|
||||
} else {
|
||||
while(this.peek(2) !== "{{" && this.peek(2) !== "") { result = result + this.getchar(); }
|
||||
return "CONTENT"
|
||||
return "CONTENT";
|
||||
}
|
||||
};
|
||||
// END(BROWSER)
|
||||
|
||||
Reference in New Issue
Block a user