tpl: Make the Namespace func signature explicit

This makes it cleaner and avoids breaking client code, such as the docs helper JSON generator.
This commit is contained in:
Bjørn Erik Pedersen
2017-05-20 11:28:33 +03:00
parent ebd636e4d5
commit 1f9e8dcc60
37 changed files with 40 additions and 40 deletions

View File

@@ -45,7 +45,7 @@ type TemplateFuncsNamespace struct {
Name string
// This is the method receiver.
Context interface{}
Context func(v ...interface{}) interface{}
// Additional info, aliases and examples, per method name.
MethodMappings map[string]TemplateFuncMethodMapping
@@ -165,7 +165,7 @@ func (t *TemplateFuncsNamespace) toJSON() ([]byte, error) {
buf.WriteString(fmt.Sprintf(`%q: {`, t.Name))
ctx := t.Context.(func() interface{})()
ctx := t.Context()
ctxType := reflect.TypeOf(ctx)
for i := 0; i < ctxType.NumMethod(); i++ {
method := ctxType.Method(i)