aboutsummaryrefslogtreecommitdiffstats
path: root/askama_parser/src/node.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-03 09:30:28 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-31 10:27:15 +0200
commit65fb5630825b62ca959fcb55252d1657aefea0f3 (patch)
tree8bad6fbd1db269e33ea1f40645a597bb4b37fc03 /askama_parser/src/node.rs
parentf16ddb14f09e470f902ea5cb93e749685dd89d6a (diff)
downloadaskama-65fb5630825b62ca959fcb55252d1657aefea0f3.tar.gz
askama-65fb5630825b62ca959fcb55252d1657aefea0f3.tar.bz2
askama-65fb5630825b62ca959fcb55252d1657aefea0f3.zip
parser: define a struct for Match
Diffstat (limited to 'askama_parser/src/node.rs')
-rw-r--r--askama_parser/src/node.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs
index 84b4911..54dc333 100644
--- a/askama_parser/src/node.rs
+++ b/askama_parser/src/node.rs
@@ -581,7 +581,12 @@ pub struct Loop<'a> {
pub ws3: Ws,
}
-pub type When<'a> = (Ws, Target<'a>, Vec<Node<'a>>);
+#[derive(Debug, PartialEq)]
+pub struct When<'a> {
+ pub ws: Ws,
+ pub target: Target<'a>,
+ pub block: Vec<Node<'a>>,
+}
#[derive(Debug, PartialEq)]
pub struct Macro<'a> {
@@ -669,7 +674,14 @@ fn match_else_block<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, When<'a>>
))),
));
let (i, (_, pws, _, (nws, _, block))) = p(i)?;
- Ok((i, (Ws(pws, nws), Target::Name("_"), block)))
+ Ok((
+ i,
+ When {
+ ws: Ws(pws, nws),
+ target: Target::Name("_"),
+ block,
+ },
+ ))
}
fn when_block<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, When<'a>> {
@@ -685,7 +697,14 @@ fn when_block<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, When<'a>> {
))),
));
let (i, (_, pws, _, (target, nws, _, block))) = p(i)?;
- Ok((i, (Ws(pws, nws), target, block)))
+ Ok((
+ i,
+ When {
+ ws: Ws(pws, nws),
+ target,
+ block,
+ },
+ ))
}
fn parse_loop_content<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, Vec<Node<'a>>> {