From 7904325c1613fa307bb9a0fb5a1d5751420a063e Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 6 Jan 2017 11:22:49 +0100 Subject: Add parser and code generator support for Filter expressions --- askama_derive/src/generator.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'askama_derive/src/generator.rs') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 3fa5b9f..0e80265 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -54,9 +54,16 @@ impl Generator { self.write(&format!("self.{}", str::from_utf8(s).unwrap())); } + fn visit_filter(&mut self, name: &str, val: &Expr) { + self.write(&format!("askama::filters::{}(&", name)); + self.visit_expr(val); + self.write(")"); + } + fn visit_expr(&mut self, expr: &Expr) { match expr { &Expr::Var(s) => self.visit_var(s), + &Expr::Filter(name, ref val) => self.visit_filter(name, &val), } } -- cgit