aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askama_shared/src/generator.rs15
-rw-r--r--testing/templates/allow-whitespaces.html3
-rw-r--r--testing/tests/whitespace.rs2
3 files changed, 9 insertions, 11 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs
index e45acb6..f56ae4b 100644
--- a/askama_shared/src/generator.rs
+++ b/askama_shared/src/generator.rs
@@ -826,10 +826,11 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
return 0;
}
- if self.buf_writable.iter().all(|w| match w {
- Writable::Lit(_) => true,
- _ => false,
- }) {
+ if self
+ .buf_writable
+ .iter()
+ .all(|w| matches!(w, Writable::Lit(_)))
+ {
let mut buf_lit = Buffer::new(0);
for s in mem::replace(&mut self.buf_writable, vec![]) {
if let Writable::Lit(s) = s {
@@ -1083,13 +1084,11 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
buf.write("&");
}
- let scoped = match *arg {
+ let scoped = matches!(arg,
Expr::Filter(_, _)
| Expr::MethodCall(_, _, _)
| Expr::VarCall(_, _)
- | Expr::PathCall(_, _) => true,
- _ => false,
- };
+ | Expr::PathCall(_, _));
if scoped {
buf.writeln("{");
diff --git a/testing/templates/allow-whitespaces.html b/testing/templates/allow-whitespaces.html
index 80f7ecd..f1acc90 100644
--- a/testing/templates/allow-whitespaces.html
+++ b/testing/templates/allow-whitespaces.html
@@ -29,7 +29,7 @@
{{ array[..]| json }}{{ array [ .. ]| json }}
{{ array[1..2]| json }}{{ array [ 1 .. 2 ]| json }}
{{ array[1..=2]| json }}{{ array [ 1 ..= 2 ]| json }}
-{{ array[(0+1)..(3-2)]| json }}{{ array [ ( 0 + 1 ) .. ( 3 - 2 ) ]| json }}
+{{ array[(0+1)..(3-2)]| json }}{{ array [ ( 0 + 1 ) .. ( 3 - 1 ) ]| json }}
{{-1}}{{ -1 }}{{ - 1 }}
{{1+2}}{{ 1+2 }}{{ 1 +2 }}{{ 1+ 2 }} {{ 1 + 2 }}
@@ -60,4 +60,3 @@
{#
{{ ::std::string::String::new () }}
#}
-
diff --git a/testing/tests/whitespace.rs b/testing/tests/whitespace.rs
index befc7d1..92d6880 100644
--- a/testing/tests/whitespace.rs
+++ b/testing/tests/whitespace.rs
@@ -37,5 +37,5 @@ fn test_extra_whitespace() {
let mut template = AllowWhitespaces::default();
template.nested_1.nested_2.array = &["a0", "a1", "a2", "a3"];
template.nested_1.nested_2.hash.insert("key", "value");
- assert_eq!(template.render().unwrap(), "\n0\n0\n0\n0\n\n\n\n0\n0\n0\n0\n0\n\na0\na1\nvalue\n\n\n\n\n\n[\n \"a0\",\n \"a1\",\n \"a2\",\n \"a3\"\n]\n[\n \"a0\",\n \"a1\",\n \"a2\",\n \"a3\"\n][\n \"a0\",\n \"a1\",\n \"a2\",\n \"a3\"\n]\n[\n \"a1\"\n][\n \"a1\"\n]\n[\n \"a1\",\n \"a2\"\n][\n \"a1\",\n \"a2\"\n]\n[][]1-1-1\n3333 3\n2222 2\n0000 0\n3333 3\n\ntruefalse\nfalsefalsefalse\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
+ assert_eq!(template.render().unwrap(), "\n0\n0\n0\n0\n\n\n\n0\n0\n0\n0\n0\n\na0\na1\nvalue\n\n\n\n\n\n[\n \"a0\",\n \"a1\",\n \"a2\",\n \"a3\"\n]\n[\n \"a0\",\n \"a1\",\n \"a2\",\n \"a3\"\n][\n \"a0\",\n \"a1\",\n \"a2\",\n \"a3\"\n]\n[\n \"a1\"\n][\n \"a1\"\n]\n[\n \"a1\",\n \"a2\"\n][\n \"a1\",\n \"a2\"\n]\n[][\n \"a1\"\n]1-1-1\n3333 3\n2222 2\n0000 0\n3333 3\n\ntruefalse\nfalsefalsefalse\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
}