mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
tpl/collections: Fix apply with namespaced template funcs
We changed the signature to `func(...interface{}) (interface{}, error)` some time ago, but sadly we had no test for this for `apply`. Now we do. Fixes #9393
This commit is contained in:
@@ -111,15 +111,25 @@ func (ns *Namespace) lookupFunc(fname string) (reflect.Value, bool) {
|
||||
|
||||
ss := strings.SplitN(fname, ".", 2)
|
||||
|
||||
// namespace
|
||||
// Namespace
|
||||
nv, found := ns.lookupFunc(ss[0])
|
||||
if !found {
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
|
||||
fn, ok := nv.Interface().(func(...interface{}) (interface{}, error))
|
||||
if !ok {
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
v, err := fn()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
nv = reflect.ValueOf(v)
|
||||
|
||||
// method
|
||||
m := nv.MethodByName(ss[1])
|
||||
// if reflect.DeepEqual(m, reflect.Value{}) {
|
||||
|
||||
if m.Kind() == reflect.Invalid {
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
|
Reference in New Issue
Block a user