Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-01-17 00:01:13 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-01-17 11:50:48 +0300
commit2655739940d8148ef374248e867b44d87cd63edf (patch)
tree80feed083fac1525d8571dd0aa87c4d304b19c7a /tpl
parent348d300a719ae5528997758ebf552691842839b3 (diff)
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
Diffstat (limited to 'tpl')
-rw-r--r--tpl/collections/apply.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/tpl/collections/apply.go b/tpl/collections/apply.go
index 86554def1..6eedb4b63 100644
--- a/tpl/collections/apply.go
+++ b/tpl/collections/apply.go
@@ -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
}