Skip to content

Commit

Permalink
fix parser bug in jinja2cpp when expression starts and ends with '. f…
Browse files Browse the repository at this point in the history
…or example: {{'hello'}}
  • Loading branch information
guocuimi committed Jan 5, 2024
1 parent bfa0bb0 commit 116ba13
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions third_party/jinja2cpp/src/template_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class TemplateParser : public LexerHelper
FinishCurrentLine(match.position() + 2);
return MakeParseError(ErrorCode::UnexpectedExprEnd, MakeToken(Token::ExprEnd, { matchStart, matchStart + 2 }));
}
else if (m_currentBlockInfo.type != TextBlockType::Expression || (*m_template)[match.position() - 1] == '\'')
else if (m_currentBlockInfo.type != TextBlockType::Expression)
break;

m_currentBlockInfo.range.startOffset = FinishCurrentBlock(matchStart, TextBlockType::RawText);
Expand All @@ -480,7 +480,7 @@ class TemplateParser : public LexerHelper
FinishCurrentLine(match.position() + 2);
return MakeParseError(ErrorCode::UnexpectedStmtEnd, MakeToken(Token::StmtEnd, { matchStart, matchStart + 2 }));
}
else if (m_currentBlockInfo.type != TextBlockType::Statement || (*m_template)[match.position() - 1] == '\'')
else if (m_currentBlockInfo.type != TextBlockType::Statement)
break;

m_currentBlockInfo.range.startOffset = FinishCurrentBlock(matchStart, TextBlockType::RawText);
Expand Down

0 comments on commit 116ba13

Please sign in to comment.