From 3e1dbe4d6ddf64596d47f5fd80f1a489c1b7673a Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 8 Aug 2017 20:45:57 +0200 Subject: Add some comments to clarify structure of the code generator --- askama_derive/src/generator.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'askama_derive') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index de2e6f2..ac23290 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -121,6 +121,8 @@ impl<'a> Generator<'a> { Self::new(self.locals, self.indent) } + /* Helper methods for writing to internal buffer */ + fn indent(&mut self) { self.indent += 1; } @@ -154,6 +156,8 @@ impl<'a> Generator<'a> { self.start = true; } + /* Helper methods for dealing with whitespace nodes */ + fn flush_ws(&mut self, ws: &WS) { if self.next_ws.is_some() && !ws.0 { let val = self.next_ws.unwrap(); @@ -174,6 +178,8 @@ impl<'a> Generator<'a> { self.prepare_ws(ws); } + /* Visitor methods for expression types */ + fn visit_num_lit(&mut self, s: &str) { self.write(s); } @@ -273,6 +279,8 @@ impl<'a> Generator<'a> { } } + /* Helper methods for handling node types */ + fn write_lit(&mut self, lws: &'a str, val: &str, rws: &'a str) { assert!(self.next_ws.is_none()); if !lws.is_empty() { -- cgit