aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-14 20:38:12 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-14 20:38:12 +0100
commit21852a33bc3c1fb6ed816ba95c5f95f88f5aa941 (patch)
tree8f1d6dcc08ec76b412b980d424e91622a006d53d
parentfe616492dcf0c5df2e42e8e0534c60543da77103 (diff)
downloadaskama-21852a33bc3c1fb6ed816ba95c5f95f88f5aa941.tar.gz
askama-21852a33bc3c1fb6ed816ba95c5f95f88f5aa941.tar.bz2
askama-21852a33bc3c1fb6ed816ba95c5f95f88f5aa941.zip
Move code for whitespace handling around
-rw-r--r--askama/src/generator.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/askama/src/generator.rs b/askama/src/generator.rs
index eee8bc5..f327d26 100644
--- a/askama/src/generator.rs
+++ b/askama/src/generator.rs
@@ -77,6 +77,26 @@ impl<'a> Generator<'a> {
self.start = true;
}
+ fn flush_ws(&mut self, ws: &WS) {
+ if self.next_ws.is_some() && !ws.0 {
+ let val = self.next_ws.unwrap();
+ if !val.is_empty() {
+ self.writeln(&format!("writer.write_str({:#?}).unwrap();",
+ val));
+ }
+ }
+ self.next_ws = None;
+ }
+
+ fn prepare_ws(&mut self, ws: &WS) {
+ self.skip_ws = ws.1;
+ }
+
+ fn handle_ws(&mut self, ws: &WS) {
+ self.flush_ws(ws);
+ self.prepare_ws(ws);
+ }
+
fn visit_str_lit(&mut self, s: &str) {
self.write(&format!("\"{}\"", s));
}
@@ -121,26 +141,6 @@ impl<'a> Generator<'a> {
}
}
- fn flush_ws(&mut self, ws: &WS) {
- if self.next_ws.is_some() && !ws.0 {
- let val = self.next_ws.unwrap();
- if !val.is_empty() {
- self.writeln(&format!("writer.write_str({:#?}).unwrap();",
- val));
- }
- }
- self.next_ws = None;
- }
-
- fn prepare_ws(&mut self, ws: &WS) {
- self.skip_ws = ws.1;
- }
-
- fn handle_ws(&mut self, ws: &WS) {
- self.flush_ws(ws);
- self.prepare_ws(ws);
- }
-
fn write_lit(&mut self, lws: &'a str, val: &str, rws: &'a str) {
assert!(self.next_ws.is_none());
if !lws.is_empty() {