diff options
author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2022-04-21 18:01:58 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-04-26 10:15:34 +0200 |
commit | e062a5ce383b7142242e641cb2105bad5cd7d078 (patch) | |
tree | 23811531009c531708ad84b608c869799156db92 /askama_shared/src | |
parent | 409e913f34253bfae9d841e150f8013bc15844dc (diff) | |
download | askama-e062a5ce383b7142242e641cb2105bad5cd7d078.tar.gz askama-e062a5ce383b7142242e641cb2105bad5cd7d078.tar.bz2 askama-e062a5ce383b7142242e641cb2105bad5cd7d078.zip |
Rename Whitespace::Trim into Whitespace::Suppress
Diffstat (limited to '')
-rw-r--r-- | askama_shared/src/generator.rs | 2 | ||||
-rw-r--r-- | askama_shared/src/parser.rs | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index 92f39c0..9174a77 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -1830,7 +1830,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { fn should_trim_ws(&self, ws: Option<Whitespace>) -> WhitespaceHandling { match ws { - Some(Whitespace::Trim) => WhitespaceHandling::Suppress, + Some(Whitespace::Suppress) => WhitespaceHandling::Suppress, Some(Whitespace::Preserve) => WhitespaceHandling::Preserve, Some(Whitespace::Minimize) => WhitespaceHandling::Minimize, None => self.whitespace, diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index 2289e09..3725681 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -132,7 +132,7 @@ pub(crate) enum Target<'a> { #[derive(Clone, Copy, Debug, PartialEq)] pub(crate) enum Whitespace { Preserve, - Trim, + Suppress, Minimize, } @@ -140,7 +140,7 @@ impl From<char> for Whitespace { fn from(c: char) -> Self { match c { '+' => Self::Preserve, - '-' => Self::Trim, + '-' => Self::Suppress, '~' => Self::Minimize, _ => panic!("unsupported `Whitespace` conversion"), } @@ -1137,7 +1137,7 @@ fn block_comment<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, Node<'a>> { )); let (i, (_, (pws, tail, _))) = p(i)?; let nws = if tail.ends_with('-') { - Some(Whitespace::Trim) + Some(Whitespace::Suppress) } else if tail.ends_with('+') { Some(Whitespace::Preserve) } else if tail.ends_with('~') { @@ -1669,31 +1669,31 @@ mod tests { ); assert_eq!( super::parse("{#- #}", s).unwrap(), - vec![Node::Comment(Ws(Some(Whitespace::Trim), None))], + vec![Node::Comment(Ws(Some(Whitespace::Suppress), None))], ); assert_eq!( super::parse("{# -#}", s).unwrap(), - vec![Node::Comment(Ws(None, Some(Whitespace::Trim)))], + vec![Node::Comment(Ws(None, Some(Whitespace::Suppress)))], ); assert_eq!( super::parse("{#--#}", s).unwrap(), vec![Node::Comment(Ws( - Some(Whitespace::Trim), - Some(Whitespace::Trim) + Some(Whitespace::Suppress), + Some(Whitespace::Suppress) ))], ); assert_eq!( super::parse("{#- foo\n bar -#}", s).unwrap(), vec![Node::Comment(Ws( - Some(Whitespace::Trim), - Some(Whitespace::Trim) + Some(Whitespace::Suppress), + Some(Whitespace::Suppress) ))], ); assert_eq!( super::parse("{#- foo\n {#- bar\n -#} baz -#}", s).unwrap(), vec![Node::Comment(Ws( - Some(Whitespace::Trim), - Some(Whitespace::Trim) + Some(Whitespace::Suppress), + Some(Whitespace::Suppress) ))], ); assert_eq!( |