diff options
author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-10-25 11:10:41 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-10-25 14:54:14 +0200 |
commit | d48ac76f0a6561cc16aa650f0f33a3d1f9e809b9 (patch) | |
tree | b43a51855f12decfbb51dd608eebf682169d43e7 | |
parent | c056d6287b0616aea9bc9fab43bcca97d0e86d23 (diff) | |
download | askama-d48ac76f0a6561cc16aa650f0f33a3d1f9e809b9.tar.gz askama-d48ac76f0a6561cc16aa650f0f33a3d1f9e809b9.tar.bz2 askama-d48ac76f0a6561cc16aa650f0f33a3d1f9e809b9.zip |
Improve error for `elif` keyword
-rw-r--r-- | askama_parser/src/node.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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), |