diff options
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 2 | ||||
-rw-r--r-- | testing/tests/calls.rs | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 65136c6..6004aff 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -1945,7 +1945,7 @@ fn is_copyable_within_op(expr: &Expr<'_>, within_op: bool) -> bool { pub(crate) fn is_attr_self(expr: &Expr<'_>) -> bool { match expr { Expr::Attr(obj, _) if matches!(obj.as_ref(), Expr::Var("self")) => true, - Expr::Attr(obj, _) if matches!(obj.as_ref(), Expr::Attr(..)) => is_attr_self(expr), + Expr::Attr(obj, _) if matches!(obj.as_ref(), Expr::Attr(..)) => is_attr_self(obj), _ => false, } } diff --git a/testing/tests/calls.rs b/testing/tests/calls.rs index 052f34f..28d7491 100644 --- a/testing/tests/calls.rs +++ b/testing/tests/calls.rs @@ -80,3 +80,22 @@ fn test_one_func_binop() { }; assert_eq!(t.render().unwrap(), "246"); } + +fn double_attr_arg_helper(x: u32) -> u32 { + x * x + x +} + +#[derive(askama::Template)] +#[template( + source = "{{ self::double_attr_arg_helper(self.x.0 + 2) }}", + ext = "txt" +)] +struct DoubleAttrArg { + x: (u32,), +} + +#[test] +fn test_double_attr_arg() { + let t = DoubleAttrArg { x: (10,) }; + assert_eq!(t.render().unwrap(), "156"); +} |