From ecae242714875524c421945cbaf0ce948dc5754a Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 27 May 2018 09:44:11 +0200 Subject: Allow methods to be called on self --- askama_derive/src/generator.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'askama_derive') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 188c521..d309abd 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -793,7 +793,12 @@ impl<'a> Generator<'a> { fn visit_method_call(&mut self, obj: &Expr, method: &str, args: &[Expr], code: &mut String) -> DisplayWrap { - self.visit_expr(obj, code); + if let &Expr::Var("self") = obj { + code.push_str("self"); + } else { + self.visit_expr(obj, code); + } + code.push_str(&format!(".{}(", method)); self._visit_args(args, code); code.push_str(")"); -- cgit