mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-02 22:52:51 +02:00
tpl: Improve template funcs GoDoc
This commit is contained in:
@@ -24,9 +24,9 @@ import (
|
||||
"github.com/gohugoio/hugo/tpl"
|
||||
)
|
||||
|
||||
// Apply takes a map, array, or slice and returns a new slice with the function fname applied over it.
|
||||
func (ns *Namespace) Apply(ctx context.Context, seq any, fname string, args ...any) (any, error) {
|
||||
if seq == nil {
|
||||
// Apply takes a map, array, or slice c and returns a new slice with the function fname applied over it.
|
||||
func (ns *Namespace) Apply(ctx context.Context, c any, fname string, args ...any) (any, error) {
|
||||
if c == nil {
|
||||
return make([]any, 0), nil
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func (ns *Namespace) Apply(ctx context.Context, seq any, fname string, args ...a
|
||||
return nil, errors.New("can't apply myself (no turtles allowed)")
|
||||
}
|
||||
|
||||
seqv := reflect.ValueOf(seq)
|
||||
seqv := reflect.ValueOf(c)
|
||||
seqv, isNil := indirect(seqv)
|
||||
if isNil {
|
||||
return nil, errors.New("can't iterate over a nil value")
|
||||
@@ -61,7 +61,7 @@ func (ns *Namespace) Apply(ctx context.Context, seq any, fname string, args ...a
|
||||
|
||||
return r, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("can't apply over %v", seq)
|
||||
return nil, fmt.Errorf("can't apply over %v", c)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user