aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-08 20:45:57 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-08 20:45:57 +0200
commit3e1dbe4d6ddf64596d47f5fd80f1a489c1b7673a (patch)
treef8c984481ad091efa7b457b2a1ddabd50efa9a60 /askama_derive/src
parentd40f5a3ea60a1f8c9d02c955835cb966873b4082 (diff)
downloadaskama-3e1dbe4d6ddf64596d47f5fd80f1a489c1b7673a.tar.gz
askama-3e1dbe4d6ddf64596d47f5fd80f1a489c1b7673a.tar.bz2
askama-3e1dbe4d6ddf64596d47f5fd80f1a489c1b7673a.zip
Add some comments to clarify structure of the code generator
Diffstat (limited to 'askama_derive/src')
-rw-r--r--askama_derive/src/generator.rs8
1 files changed, 8 insertions, 0 deletions
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() {