From d48ac76f0a6561cc16aa650f0f33a3d1f9e809b9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 25 Oct 2023 11:10:41 +0200 Subject: Improve error for `elif` keyword --- askama_parser/src/node.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'askama_parser/src/node.rs') diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs index 93fca73..dc05f48 100644 --- a/askama_parser/src/node.rs +++ b/askama_parser/src/node.rs @@ -299,7 +299,15 @@ impl<'a> Cond<'a> { let mut p = tuple(( |i| s.tag_block_start(i), opt(Whitespace::parse), - ws(keyword("else")), + ws(alt((keyword("else"), |i| { + let _ = keyword("elif")(i)?; + Err(nom::Err::Failure(ErrorContext { + input: i, + message: Some(Cow::Borrowed( + "unknown `elif` keyword; did you mean `else if`?", + )), + })) + }))), cut(tuple(( opt(|i| CondTest::parse(i, s)), opt(Whitespace::parse), -- cgit