diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-05-27 09:44:11 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-05-27 09:44:53 +0200 |
commit | ecae242714875524c421945cbaf0ce948dc5754a (patch) | |
tree | 653ebe70b3610e100bc2c8abe4ec5207781314ce /askama_derive | |
parent | 33acf1b1a20fdfdcac15061ee3eb847b19309b5a (diff) | |
download | askama-ecae242714875524c421945cbaf0ce948dc5754a.tar.gz askama-ecae242714875524c421945cbaf0ce948dc5754a.tar.bz2 askama-ecae242714875524c421945cbaf0ce948dc5754a.zip |
Allow methods to be called on self
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 7 |
1 files changed, 6 insertions, 1 deletions
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(")"); |