From d497a31e059292f7b37b46c6f17b489e9f3623b0 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 4 Oct 2017 21:08:43 +0200 Subject: Handle path expressions (fixes #56) --- askama_shared/src/generator.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'askama_shared/src/generator.rs') diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index ab861dc..4588677 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -561,6 +561,7 @@ impl<'a> Generator<'a> { Expr::NumLit(s) => self.visit_num_lit(s), Expr::StrLit(s) => self.visit_str_lit(s), Expr::Var(s) => self.visit_var(s), + Expr::Path(ref path) => self.visit_path(path), 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) => @@ -671,6 +672,16 @@ impl<'a> Generator<'a> { DisplayWrap::Unwrapped } + fn visit_path(&mut self, path: &Vec<&str>) -> DisplayWrap { + for (i, part) in path.iter().enumerate() { + if i > 0 { + self.write("::"); + } + self.write(part); + } + DisplayWrap::Unwrapped + } + fn visit_var(&mut self, s: &str) -> DisplayWrap { if self.locals.contains(s) { self.write(s); -- cgit