Make the ID node capable of handling paths
TODO: handle invalid paths in the tokenizer or parser
TODO: invalidate "{{ foo/ bar }}"
This commit is contained in:
@@ -33,6 +33,11 @@ Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
if(lookahead === "") return;
|
||||
|
||||
if(this.state == "MUSTACHE") {
|
||||
if(this.peek() === "/") {
|
||||
this.getchar();
|
||||
return "SEP";
|
||||
}
|
||||
|
||||
// chomp optional whitespace
|
||||
while(this.peek() === " ") { this.ignorechar(); }
|
||||
|
||||
@@ -64,7 +69,7 @@ Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
// 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() }
|
||||
|
||||
// if any characters were grabbed => ID
|
||||
if(this.yytext.length) { return "ID" }
|
||||
|
||||
@@ -79,7 +79,12 @@ Handlebars.PrintVisitor.prototype.STRING = function(string) {
|
||||
};
|
||||
|
||||
Handlebars.PrintVisitor.prototype.ID = function(id) {
|
||||
return "ID:" + id.id;
|
||||
var path = id.id.join("/");
|
||||
if(id.id.length > 1) {
|
||||
return "PATH:" + path;
|
||||
} else {
|
||||
return "ID:" + path;
|
||||
}
|
||||
};
|
||||
|
||||
Handlebars.PrintVisitor.prototype.content = function(content) {
|
||||
|
||||
Reference in New Issue
Block a user