mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
template: add some missing test cases for First
This commit is contained in:
@@ -289,6 +289,11 @@ func indirect(v reflect.Value) (rv reflect.Value, isNil bool) {
|
||||
// First is exposed to templates, to iterate over the first N items in a
|
||||
// rangeable list.
|
||||
func First(limit interface{}, seq interface{}) (interface{}, error) {
|
||||
|
||||
if limit == nil || seq == nil {
|
||||
return nil, errors.New("both limit and seq must be provided")
|
||||
}
|
||||
|
||||
limitv, err := cast.ToIntE(limit)
|
||||
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user