mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-01 06:51:15 +00:00
parser: understand arbitrarily mixed up end nodes
This commit is contained in:
parent
e0a7d4df55
commit
5efd31310f
@ -1058,7 +1058,7 @@ fn end_node<'a, 'g: 'a>(
|
||||
let (i, actual) = ws(identifier)(start)?;
|
||||
if actual == expected {
|
||||
Ok((i, actual))
|
||||
} else if actual == "end" {
|
||||
} else if actual.starts_with("end") {
|
||||
Err(nom::Err::Failure(ErrorContext::new(
|
||||
format!("expected `{expected}` to terminate `{node}` node, found `{actual}`"),
|
||||
start,
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: failed to parse template source
|
||||
error: expected `endfor` to terminate `for` node, found `endfo`
|
||||
--> <source attribute>:1:26
|
||||
"endfo%}\n1234567890123456789012345678901234567890"
|
||||
--> tests/ui/typo_in_keyword.rs:5:14
|
||||
|
@ -24,4 +24,8 @@ struct Block;
|
||||
#[template(source = "{% if true %}{% end %}", ext = "txt")]
|
||||
struct If;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(source = "{% if true %}{% endfor %}", ext = "txt")]
|
||||
struct IfFor;
|
||||
|
||||
fn main() {}
|
||||
|
@ -45,3 +45,11 @@ error: expected `endif` to terminate `if` node, found `end`
|
||||
|
|
||||
24 | #[template(source = "{% if true %}{% end %}", ext = "txt")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: expected `endif` to terminate `if` node, found `endfor`
|
||||
--> <source attribute>:1:15
|
||||
" endfor %}"
|
||||
--> tests/ui/wrong-end.rs:28:21
|
||||
|
|
||||
28 | #[template(source = "{% if true %}{% endfor %}", ext = "txt")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
Loading…
x
Reference in New Issue
Block a user