Add a page template func

Fixes #9339
This commit is contained in:
Bjørn Erik Pedersen
2023-02-25 09:24:59 +01:00
parent 2662faf61f
commit ce524d0b5e
54 changed files with 436 additions and 108 deletions

View File

@@ -159,12 +159,7 @@ func (p Pages) GroupBy(ctx context.Context, key string, order ...string) (PagesG
case reflect.StructField:
fv = ppv.Elem().FieldByName(key)
case reflect.Method:
var args []reflect.Value
fn := hreflect.GetMethodByName(ppv, key)
if fn.Type().NumIn() > 0 && fn.Type().In(0).Implements(hreflect.ContextInterface) {
args = []reflect.Value{reflect.ValueOf(ctx)}
}
fv = fn.Call(args)[0]
fv = hreflect.CallMethodByName(ctx, key, ppv)[0]
}
if !fv.IsValid() {
continue