Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit d48ac76

Browse files
GuillaumeGomezdjc
authored andcommitted
Improve error for elif keyword
1 parent c056d62 commit d48ac76

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

askama_parser/src/node.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,15 @@ impl<'a> Cond<'a> {
299299
let mut p = tuple((
300300
|i| s.tag_block_start(i),
301301
opt(Whitespace::parse),
302-
ws(keyword("else")),
302+
ws(alt((keyword("else"), |i| {
303+
let _ = keyword("elif")(i)?;
304+
Err(nom::Err::Failure(ErrorContext {
305+
input: i,
306+
message: Some(Cow::Borrowed(
307+
"unknown `elif` keyword; did you mean `else if`?",
308+
)),
309+
}))
310+
}))),
303311
cut(tuple((
304312
opt(|i| CondTest::parse(i, s)),
305313
opt(Whitespace::parse),

0 commit comments

Comments
 (0)