diff options
author | bott <mhpoin@gmail.com> | 2018-10-07 17:13:52 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-10-07 17:26:08 +0200 |
commit | 28d76964080f5c6c36d5f6ed72828b679fe352b4 (patch) | |
tree | 7056ea52905791893fd1681fd2297aac13389851 /askama_derive/src/generator.rs | |
parent | 9edf27d9446da0b6c00550544d37b6da633bd2b6 (diff) | |
download | askama-28d76964080f5c6c36d5f6ed72828b679fe352b4.tar.gz askama-28d76964080f5c6c36d5f6ed72828b679fe352b4.tar.bz2 askama-28d76964080f5c6c36d5f6ed72828b679fe352b4.zip |
Add Rust macro support at templates
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r-- | askama_derive/src/generator.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 33fbe4c..41e1647 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -644,10 +644,20 @@ impl<'a> Generator<'a> { Expr::Group(ref inner) => self.visit_group(buf, inner), Expr::MethodCall(ref obj, method, ref args) => { self.visit_method_call(buf, obj, method, args) - } + }, + Expr::RustMacro(name, ref args) => self.visit_rust_macro(buf, name, args), } } + fn visit_rust_macro(&mut self, buf: &mut Buffer, name: &str, args: &[Expr]) -> DisplayWrap { + buf.write(name); + buf.write("!("); + self._visit_args(buf, args); + buf.write(")"); + + DisplayWrap::Unwrapped + } + fn visit_match_variant(&mut self, buf: &mut Buffer, param: &MatchVariant) -> DisplayWrap { let mut expr_buf = Buffer::new(0); let wrapped = match *param { |