aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-08 14:16:15 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-08 14:16:15 +0100
commit38c31ee4bd2c0853fa5b82c1474af16cf5b33d88 (patch)
tree9759e7a8b8f45bda8c4d61582c2e3d1cf38e3ac5
parent0a26ac76448ce210b2c5d3820c014ec1c82642e8 (diff)
downloadaskama-38c31ee4bd2c0853fa5b82c1474af16cf5b33d88.tar.gz
askama-38c31ee4bd2c0853fa5b82c1474af16cf5b33d88.tar.bz2
askama-38c31ee4bd2c0853fa5b82c1474af16cf5b33d88.zip
Move handling of Node::Lit parts into write_lit() method
-rw-r--r--askama/src/generator.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/askama/src/generator.rs b/askama/src/generator.rs
index 5fe127e..ecc1887 100644
--- a/askama/src/generator.rs
+++ b/askama/src/generator.rs
@@ -117,8 +117,10 @@ impl Generator {
}
}
- fn write_lit(&mut self, s: &str) {
- self.write(&format!("writer.write_str({:#?}).unwrap();", s));
+ fn write_lit(&mut self, lws: &str, val: &str, rws: &str) {
+ self.write(&format!("writer.write_str({:#?}).unwrap();", lws));
+ self.write(&format!("writer.write_str({:#?}).unwrap();", val));
+ self.write(&format!("writer.write_str({:#?}).unwrap();", rws));
}
fn write_expr(&mut self, s: &Expr) {
@@ -187,11 +189,7 @@ impl Generator {
fn handle(&mut self, nodes: &[Node]) {
for n in nodes {
match *n {
- Node::Lit(lws, val, rws) => {
- self.write_lit(lws);
- self.write_lit(val);
- self.write_lit(rws);
- },
+ Node::Lit(lws, val, rws) => { self.write_lit(lws, val, rws); }
Node::Expr(_, ref val) => { self.write_expr(val); },
Node::Cond(ref conds, _) => { self.write_cond(conds); },
Node::Loop(_, ref var, ref iter, ref body, _) => {