diff options
author | Nathan Lapel <nathanlapel@gmail.com> | 2020-03-18 22:09:00 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-03-18 22:33:51 +0100 |
commit | 5e1a7384e47e01157d6a8b3beb42b57026c417e8 (patch) | |
tree | b58f821d2bbedfc5744fddd5042fe90656e10434 | |
parent | 520c5d7d5f09c0b205e6e1c471483730380c5e33 (diff) | |
download | askama-5e1a7384e47e01157d6a8b3beb42b57026c417e8.tar.gz askama-5e1a7384e47e01157d6a8b3beb42b57026c417e8.tar.bz2 askama-5e1a7384e47e01157d6a8b3beb42b57026c417e8.zip |
Use _visit_args in var/path calls
Diffstat (limited to '')
-rw-r--r-- | askama_shared/src/generator.rs | 23 | ||||
-rw-r--r-- | testing/tests/simple.rs | 6 |
2 files changed, 11 insertions, 18 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index fb8619e..d904524 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -1030,7 +1030,10 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { } let scoped = match *arg { - Expr::Filter(_, _) | Expr::MethodCall(_, _, _) => true, + Expr::Filter(_, _) + | Expr::MethodCall(_, _, _) + | Expr::VarCall(_, _) + | Expr::PathCall(_, _) => true, _ => false, }; @@ -1169,13 +1172,8 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { } buf.write(part); } - buf.write("("); - for (i, arg) in args.iter().enumerate() { - if i > 0 { - buf.write(","); - } - self.visit_expr(buf, arg); - } + buf.write("(&"); + self._visit_args(buf, args); buf.write(")"); DisplayWrap::Unwrapped } @@ -1198,13 +1196,8 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { buf.write("self."); buf.write(s); } - buf.write(")("); - for (i, arg) in args.iter().enumerate() { - if i > 0 { - buf.write(","); - } - self.visit_expr(buf, arg); - } + buf.write(")(&"); + self._visit_args(buf, args); buf.write(")"); DisplayWrap::Unwrapped } diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 3e156b4..7dcacba 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -265,7 +265,7 @@ fn test_slice_literal() { #[derive(Template)] #[template(source = "Hello, {{ world(\"123\", 4) }}!", ext = "txt")] struct FunctionRefTemplate { - world: fn(s: &str, v: u8) -> String, + world: fn(s: &str, v: &u8) -> String, } #[test] @@ -276,7 +276,7 @@ fn test_func_ref_call() { assert_eq!(t.render().unwrap(), "Hello, world(123, 4)!"); } -fn world2(s: &str, v: u8) -> String { +fn world2(s: &str, v: &u8) -> String { format!("world{}{}", v, s) } @@ -294,7 +294,7 @@ fn test_path_func_call() { struct FunctionTemplate; impl FunctionTemplate { - fn world3(&self, s: &str, v: u8) -> String { + fn world3(&self, s: &str, v: &u8) -> String { format!("world{}{}", s, v) } } |