aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar bott <mhpoin@gmail.com>2018-11-11 21:53:54 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-11-11 22:39:22 +0100
commit7e6eda2f69fbe104be3823cabc31af9307b83a38 (patch)
tree7d2a73af5736240ae99a00193363669965eb5a9e /askama_derive/src/generator.rs
parent75098f3561aa4dc0e030ee08d8bb85a49d6ba784 (diff)
downloadaskama-7e6eda2f69fbe104be3823cabc31af9307b83a38.tar.gz
askama-7e6eda2f69fbe104be3823cabc31af9307b83a38.tar.bz2
askama-7e6eda2f69fbe104be3823cabc31af9307b83a38.zip
Fix write expression wrapper
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r--askama_derive/src/generator.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 38eca55..8b75e21 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -630,7 +630,7 @@ impl<'a> Generator<'a> {
buf.writeln(&format!("writer.write_str({:#?})?;", &buf_lit.buf));
return;
}
-
+
let mut buf_format = Buffer::new(0);
let mut buf_expr = Buffer::new(buf.indent + 1);
let mut expr_cache = HashMap::with_capacity(self.buf_writable.len());
@@ -646,23 +646,20 @@ impl<'a> Generator<'a> {
let wrapped = self.visit_expr(&mut expr_buf, s);
let expression = match (wrapped, &self.input.escaping) {
(Wrapped, &Html) | (Wrapped, &None) | (Unwrapped, &None) => {
- expr_buf.buf.clone()
+ expr_buf.buf
}
(Unwrapped, &Html) => {
- format!(
- "::askama::MarkupDisplay::from(&{})",
- expr_buf.buf.clone()
- )
+ format!("::askama::MarkupDisplay::from(&{})", expr_buf.buf)
}
};
- let id = expr_cache.entry(expression).or_insert_with(|| {
+ let id = expr_cache.entry(expression.clone()).or_insert_with(|| {
let id = self.named;
self.named += 1;
buf_expr.write(&format!("expr{} = ", id));
buf_expr.write("&");
- buf_expr.write(&expr_buf.buf);
+ buf_expr.write(&expression);
buf_expr.writeln(",");
id