mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Refactor var name limit to index
This commit is contained in:
parent
40a92a062d
commit
627d016cc9
1 changed files with 6 additions and 6 deletions
|
@ -390,19 +390,19 @@ func First(limit interface{}, seq interface{}) (interface{}, error) {
|
||||||
|
|
||||||
// After is exposed to templates, to iterate over all the items after N in a
|
// After is exposed to templates, to iterate over all the items after N in a
|
||||||
// rangeable list. It's meant to accompany First
|
// rangeable list. It's meant to accompany First
|
||||||
func After(limit interface{}, seq interface{}) (interface{}, error) {
|
func After(index interface{}, seq interface{}) (interface{}, error) {
|
||||||
|
|
||||||
if limit == nil || seq == nil {
|
if index == nil || seq == nil {
|
||||||
return nil, errors.New("both limit and seq must be provided")
|
return nil, errors.New("both limit and seq must be provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
limitv, err := cast.ToIntE(limit)
|
indexv, err := cast.ToIntE(index)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if limitv < 1 {
|
if indexv < 1 {
|
||||||
return nil, errors.New("can't return negative/empty count of items from sequence")
|
return nil, errors.New("can't return negative/empty count of items from sequence")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,10 +418,10 @@ func After(limit interface{}, seq interface{}) (interface{}, error) {
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("can't iterate over " + reflect.ValueOf(seq).Type().String())
|
return nil, errors.New("can't iterate over " + reflect.ValueOf(seq).Type().String())
|
||||||
}
|
}
|
||||||
if limitv >= seqv.Len() {
|
if indexv >= seqv.Len() {
|
||||||
return nil, errors.New("no items left")
|
return nil, errors.New("no items left")
|
||||||
}
|
}
|
||||||
return seqv.Slice(limitv, seqv.Len()).Interface(), nil
|
return seqv.Slice(indexv, seqv.Len()).Interface(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in a new issue