diff options
Diffstat (limited to 'askama_derive/src')
-rw-r--r-- | askama_derive/src/generator.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 5921609..e8d15f6 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -1196,11 +1196,12 @@ impl<'a> Generator<'a> { expr_buf.buf, self.input.escaper ), }; + let is_cacheable = !matches!(s, Expr::Call(..)); use std::collections::hash_map::Entry; let id = match expr_cache.entry(expression.clone()) { - Entry::Occupied(e) => *e.get(), - Entry::Vacant(e) => { + Entry::Occupied(e) if is_cacheable => *e.get(), + e => { let id = self.named; self.named += 1; @@ -1209,7 +1210,10 @@ impl<'a> Generator<'a> { buf_expr.write(&expression); buf_expr.writeln(",")?; - e.insert(id); + if let Entry::Vacant(e) = e { + e.insert(id); + } + id } }; |