mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00
Fixed loop generator when accessing field (fixes 494)
This commit is contained in:
parent
49252d2457
commit
e70e8f7c1d
@ -658,6 +658,12 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
|
||||
", _loop_item) in ::askama::helpers::TemplateLoop::new(((&{}).into_iter())) {{",
|
||||
expr_code
|
||||
)),
|
||||
// If accessing a field then it most likely needs to be
|
||||
// borrowed, to prevent an attempt of moving.
|
||||
Expr::Attr(..) => buf.writeln(&format!(
|
||||
", _loop_item) in ::askama::helpers::TemplateLoop::new(((&{}).into_iter())) {{",
|
||||
expr_code
|
||||
)),
|
||||
// Otherwise, we borrow `iter` assuming that it implements `IntoIterator`.
|
||||
_ => buf.writeln(&format!(
|
||||
", _loop_item) in ::askama::helpers::TemplateLoop::new(({}).into_iter()) {{",
|
||||
|
Loading…
x
Reference in New Issue
Block a user