diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-22 17:47:06 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-22 18:54:34 +0200 |
commit | b6e6438f7f742cada5126aa59e856f8531dc6420 (patch) | |
tree | 90df094f886316fb94ffdb55a91988b0fe59cfd8 /tpl | |
parent | 943ff7f7ce14a1e7edc195684036000efea5fb7f (diff) |
docs: Regen docshelper
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/internal/templatefuncsRegistry.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tpl/internal/templatefuncsRegistry.go b/tpl/internal/templatefuncsRegistry.go index 363f6d82f..eea14372b 100644 --- a/tpl/internal/templatefuncsRegistry.go +++ b/tpl/internal/templatefuncsRegistry.go @@ -170,14 +170,17 @@ func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error) { buf.WriteString("{") for i, ns := range namespaces { - if i != 0 { - buf.WriteString(",") - } + b, err := ns.toJSON(context.TODO()) if err != nil { return nil, err } - buf.Write(b) + if b != nil { + if i != 0 { + buf.WriteString(",") + } + buf.Write(b) + } } buf.WriteString("}") @@ -202,6 +205,11 @@ func (t *TemplateFuncsNamespace) toJSON(ctx context.Context) ([]byte, error) { if err != nil { return nil, err } + if tctx == nil { + // E.g. page. + // We should fix this, but we're going to abandon this construct in a little while. + return nil, nil + } ctxType := reflect.TypeOf(tctx) for i := 0; i < ctxType.NumMethod(); i++ { method := ctxType.Method(i) |