From 8d8374a10f09729b403f3519a7bceac919c484c3 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 17 Apr 2018 17:34:44 +0200 Subject: Properly handle whitespace around comments (fixes #79) --- askama_derive/src/generator.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'askama_derive/src/generator.rs') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 0ff30ed..449a969 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -310,7 +310,9 @@ impl<'a> Generator<'a> { Node::Lit(lws, val, rws) => { self.write_lit(lws, val, rws); }, - Node::Comment() => {}, + Node::Comment(ref ws) => { + self.write_comment(ws); + }, Node::Expr(ref ws, ref val) => { self.write_expr(state, ws, val); }, @@ -600,6 +602,10 @@ impl<'a> Generator<'a> { } } + fn write_comment(&mut self, ws: &WS) { + self.handle_ws(ws); + } + /* Visitor methods for expression types */ fn visit_expr_root(&mut self, expr: &Expr) -> DisplayWrap { -- cgit