mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 05:21:14 +00:00
Merge pull request #436 from Kijewski/pr-no-loop-first
`loop.first` is known by being at `index == 0`
This commit is contained in:
commit
428ff19932
@ -48,7 +48,6 @@ where
|
||||
item,
|
||||
LoopItem {
|
||||
index,
|
||||
first: index == 0,
|
||||
last: self.iter.peek().is_none(),
|
||||
},
|
||||
)
|
||||
@ -59,7 +58,6 @@ where
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct LoopItem {
|
||||
pub index: usize,
|
||||
pub first: bool,
|
||||
pub last: bool,
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ impl<'a> Generator<'a, '_> {
|
||||
buf.write("_loop_item.index");
|
||||
return Ok(DisplayWrap::Unwrapped);
|
||||
} else if attr.name == "first" {
|
||||
buf.write("_loop_item.first");
|
||||
buf.write("(_loop_item.index == 0)");
|
||||
return Ok(DisplayWrap::Unwrapped);
|
||||
} else if attr.name == "last" {
|
||||
buf.write("_loop_item.last");
|
||||
|
Loading…
x
Reference in New Issue
Block a user