diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-10-20 10:09:50 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-10-20 10:09:50 +0200 |
commit | 4af73a868c7d35641f8a1bcd0a82f8c7db411d8d (patch) | |
tree | 1161aad02f2e453c1f800bc6a1730fbfb8bea671 /askama_shared/src/generator.rs | |
parent | 3d9048ab50b1030ff741371ed0d853fcc3ab5780 (diff) | |
download | askama-4af73a868c7d35641f8a1bcd0a82f8c7db411d8d.tar.gz askama-4af73a868c7d35641f8a1bcd0a82f8c7db411d8d.tar.bz2 askama-4af73a868c7d35641f8a1bcd0a82f8c7db411d8d.zip |
Add support for array literals (fixes #59)
Diffstat (limited to '')
-rw-r--r-- | askama_shared/src/generator.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index f58d1dd..dcdea32 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -573,6 +573,7 @@ impl<'a> Generator<'a> { Expr::StrLit(s) => self.visit_str_lit(s), Expr::Var(s) => self.visit_var(s), Expr::Path(ref path) => self.visit_path(path), + Expr::Array(ref elements) => self.visit_array(elements), Expr::Attr(ref obj, name) => self.visit_attr(obj, name), Expr::Filter(name, ref args) => self.visit_filter(name, args), Expr::BinOp(op, ref left, ref right) => @@ -683,6 +684,18 @@ impl<'a> Generator<'a> { DisplayWrap::Unwrapped } + fn visit_array(&mut self, elements: &Vec<Expr>) -> DisplayWrap { + self.write("["); + for (i, el) in elements.iter().enumerate() { + if i > 0 { + self.write(", "); + } + self.visit_expr(el); + } + self.write("]"); + DisplayWrap::Unwrapped + } + fn visit_path(&mut self, path: &Vec<&str>) -> DisplayWrap { for (i, part) in path.iter().enumerate() { if i > 0 { |