mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-02 22:52:51 +02:00
tpl: Last now accepts 0 as limit
Modified the if conditional because of which last threw an error if 0 was passed as limit. The function now returns an empty slice if it is called with 0 as limit. The behavior of first and last is now the same when 0 is passed as limit. Also added tests to test the new behavior. Fixes #6419
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
5f1aafafb4
commit
0e75af74db
@@ -378,7 +378,7 @@ func (ns *Namespace) Last(limit interface{}, seq interface{}) (interface{}, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if limitv < 1 {
|
||||
if limitv < 0 {
|
||||
return nil, errors.New("can't return negative/empty count of items from sequence")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user