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
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-08-01 13:50:37 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-08-01 14:39:30 +0300
commit6c70e1f22f365322d5f754302e110c9ed716b215 (patch)
treebcf30eb942afad09a2a7f56e0d0f490614ec1311 /tpl/internal
parent4d221ce468a1209ee9dd6cbece9d1273dad6a29b (diff)
Fix error handling for the time func alias
Fixes #8835
Diffstat (limited to 'tpl/internal')
-rw-r--r--tpl/internal/templatefuncsRegistry.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/tpl/internal/templatefuncsRegistry.go b/tpl/internal/templatefuncsRegistry.go
index 6d58d8d2b..df300a5bb 100644
--- a/tpl/internal/templatefuncsRegistry.go
+++ b/tpl/internal/templatefuncsRegistry.go
@@ -49,7 +49,7 @@ type TemplateFuncsNamespace struct {
Name string
// This is the method receiver.
- Context func(v ...interface{}) interface{}
+ Context func(v ...interface{}) (interface{}, error)
// Additional info, aliases and examples, per method name.
MethodMappings map[string]TemplateFuncMethodMapping
@@ -172,7 +172,10 @@ func (t *TemplateFuncsNamespace) toJSON() ([]byte, error) {
buf.WriteString(fmt.Sprintf(`%q: {`, t.Name))
- ctx := t.Context()
+ ctx, err := t.Context()
+ if err != nil {
+ return nil, err
+ }
ctxType := reflect.TypeOf(ctx)
for i := 0; i < ctxType.NumMethod(); i++ {
method := ctxType.Method(i)