aboutsummaryrefslogtreecommitdiffstats
path: root/askama_parser/src/node.rs
diff options
context:
space:
mode:
authorLibravatar Guillaume Gomez <guillaume1.gomez@gmail.com>2023-10-25 11:10:41 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-10-25 14:54:14 +0200
commitd48ac76f0a6561cc16aa650f0f33a3d1f9e809b9 (patch)
treeb43a51855f12decfbb51dd608eebf682169d43e7 /askama_parser/src/node.rs
parentc056d6287b0616aea9bc9fab43bcca97d0e86d23 (diff)
downloadaskama-d48ac76f0a6561cc16aa650f0f33a3d1f9e809b9.tar.gz
askama-d48ac76f0a6561cc16aa650f0f33a3d1f9e809b9.tar.bz2
askama-d48ac76f0a6561cc16aa650f0f33a3d1f9e809b9.zip
Improve error for `elif` keyword
Diffstat (limited to 'askama_parser/src/node.rs')
-rw-r--r--askama_parser/src/node.rs10
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),