diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-01-06 11:22:49 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-01-06 13:08:29 +0100 |
commit | 7904325c1613fa307bb9a0fb5a1d5751420a063e (patch) | |
tree | 8f6828b37f10ba61f5ff7b0272f2603a79aefc41 /askama_derive/src/generator.rs | |
parent | 856d2d7a27d9bb40aba0bcca60a9a5c82939bce2 (diff) | |
download | askama-7904325c1613fa307bb9a0fb5a1d5751420a063e.tar.gz askama-7904325c1613fa307bb9a0fb5a1d5751420a063e.tar.bz2 askama-7904325c1613fa307bb9a0fb5a1d5751420a063e.zip |
Add parser and code generator support for Filter expressions
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r-- | askama_derive/src/generator.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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), } } |