aboutsummaryrefslogtreecommitdiffstats
path: root/askama_parser/src/node.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-03 10:50:41 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-31 10:27:15 +0200
commitf9b2259cb7993d9aa0aab5745247c02206c524cf (patch)
treeaa60a15787dd586c433a3976f960cb1f5c0fe9e1 /askama_parser/src/node.rs
parent447aab0f105a71f44891751f94a5cc9f508f774d (diff)
downloadaskama-f9b2259cb7993d9aa0aab5745247c02206c524cf.tar.gz
askama-f9b2259cb7993d9aa0aab5745247c02206c524cf.tar.bz2
askama-f9b2259cb7993d9aa0aab5745247c02206c524cf.zip
parser: reorder items in node module
Diffstat (limited to 'askama_parser/src/node.rs')
-rw-r--r--askama_parser/src/node.rs100
1 files changed, 50 insertions, 50 deletions
diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs
index 4e916fc..2a19ee9 100644
--- a/askama_parser/src/node.rs
+++ b/askama_parser/src/node.rs
@@ -578,42 +578,6 @@ impl<'a> Target<'a> {
}
}
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum Whitespace {
- Preserve,
- Suppress,
- Minimize,
-}
-
-impl Whitespace {
- fn parse(i: &str) -> IResult<&str, Self> {
- alt((char('-'), char('+'), char('~')))(i).map(|(s, r)| (s, Self::from(r)))
- }
-}
-
-impl From<char> for Whitespace {
- fn from(c: char) -> Self {
- match c {
- '+' => Self::Preserve,
- '-' => Self::Suppress,
- '~' => Self::Minimize,
- _ => panic!("unsupported `Whitespace` conversion"),
- }
- }
-}
-
-#[derive(Debug, PartialEq)]
-pub struct Loop<'a> {
- pub ws1: Ws,
- pub var: Target<'a>,
- pub iter: Expr<'a>,
- pub cond: Option<Expr<'a>>,
- pub body: Vec<Node<'a>>,
- pub ws2: Ws,
- pub else_block: Vec<Node<'a>>,
- pub ws3: Ws,
-}
-
#[derive(Debug, PartialEq)]
pub struct When<'a> {
pub ws: Ws,
@@ -670,20 +634,6 @@ impl<'a> When<'a> {
}
#[derive(Debug, PartialEq)]
-pub struct Macro<'a> {
- pub ws1: Ws,
- pub args: Vec<&'a str>,
- pub nodes: Vec<Node<'a>>,
- pub ws2: Ws,
-}
-
-/// First field is "minus/plus sign was used on the left part of the item".
-///
-/// Second field is "minus/plus sign was used on the right part of the item".
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub struct Ws(pub Option<Whitespace>, pub Option<Whitespace>);
-
-#[derive(Debug, PartialEq)]
pub struct Cond<'a> {
pub ws: Ws,
pub cond: Option<CondTest<'a>>,
@@ -738,3 +688,53 @@ impl<'a> CondTest<'a> {
Ok((i, Self { target, expr }))
}
}
+
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum Whitespace {
+ Preserve,
+ Suppress,
+ Minimize,
+}
+
+impl Whitespace {
+ fn parse(i: &str) -> IResult<&str, Self> {
+ alt((char('-'), char('+'), char('~')))(i).map(|(s, r)| (s, Self::from(r)))
+ }
+}
+
+impl From<char> for Whitespace {
+ fn from(c: char) -> Self {
+ match c {
+ '+' => Self::Preserve,
+ '-' => Self::Suppress,
+ '~' => Self::Minimize,
+ _ => panic!("unsupported `Whitespace` conversion"),
+ }
+ }
+}
+
+#[derive(Debug, PartialEq)]
+pub struct Loop<'a> {
+ pub ws1: Ws,
+ pub var: Target<'a>,
+ pub iter: Expr<'a>,
+ pub cond: Option<Expr<'a>>,
+ pub body: Vec<Node<'a>>,
+ pub ws2: Ws,
+ pub else_block: Vec<Node<'a>>,
+ pub ws3: Ws,
+}
+
+#[derive(Debug, PartialEq)]
+pub struct Macro<'a> {
+ pub ws1: Ws,
+ pub args: Vec<&'a str>,
+ pub nodes: Vec<Node<'a>>,
+ pub ws2: Ws,
+}
+
+/// First field is "minus/plus sign was used on the left part of the item".
+///
+/// Second field is "minus/plus sign was used on the right part of the item".
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub struct Ws(pub Option<Whitespace>, pub Option<Whitespace>);