diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-11-07 21:33:42 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-11-07 21:33:43 +0100 |
commit | 01ba878158013b8e986387c077bf645b44679ba7 (patch) | |
tree | ec77c5a60b080ba5152ca7c0c2e771cbebf85067 | |
parent | af17585465113def637f03262181a46d6b6b9dd8 (diff) | |
download | askama-01ba878158013b8e986387c077bf645b44679ba7.tar.gz askama-01ba878158013b8e986387c077bf645b44679ba7.tar.bz2 askama-01ba878158013b8e986387c077bf645b44679ba7.zip |
Add some documentation for whitespace suppression helpers
-rw-r--r-- | askama_shared/src/generator.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index 356c927..402cd1a 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -821,11 +821,16 @@ impl<'a> Generator<'a> { /* Helper methods for dealing with whitespace nodes */ + // Combines `flush_ws()` and `prepare_ws()` to handle both trailing whitespace from the + // preceding literal and leading whitespace from the succeeding literal. fn handle_ws(&mut self, ws: &WS) { self.flush_ws(ws); self.prepare_ws(ws); } + // If the previous literal left some trailing whitespace in `next_ws` and the + // prefix whitespace suppressor from the given argument, flush that whitespace. + // In either case, `next_ws` is reset to `None` (no trailing whitespace). fn flush_ws(&mut self, ws: &WS) { if self.next_ws.is_some() && !ws.0 { let val = self.next_ws.unwrap(); @@ -837,6 +842,9 @@ impl<'a> Generator<'a> { self.next_ws = None; } + // Sets `skip_ws` to match the suffix whitespace suppressor from the given + // argument, to determine whether to suppress leading whitespace from the + // next literal. fn prepare_ws(&mut self, ws: &WS) { self.skip_ws = ws.1; } |