Skip to content

Commit

Permalink
deprecate substr method and use existing strip function in grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
liqiang372 committed Mar 13, 2019
1 parent 5cedd62 commit 445ae12
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/handlebars/compiler/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function SourceLocation(source, locInfo) {

export function id(token) {
if (/^\[.*\]$/.test(token)) {
return token.substr(1, token.length - 2);
return token.substring(1, token.length - 1);
} else {
return token;
}
Expand Down
4 changes: 2 additions & 2 deletions src/handlebars.l
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%{

function strip(start, end) {
return yytext = yytext.substr(start, yyleng-end);
return yytext = yytext.substring(start, yyleng - end + start);
}

%}
Expand Down Expand Up @@ -59,7 +59,7 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD}
if (this.conditionStack[this.conditionStack.length-1] === 'raw') {
return 'CONTENT';
} else {
yytext = yytext.substr(5, yyleng-9);
strip(5, 9);
return 'END_RAW_BLOCK';
}
}
Expand Down

0 comments on commit 445ae12

Please sign in to comment.