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

@@ -26,7 +26,7 @@ func init() {
ns := &internal.TemplateFuncsNamespace{
Name: name,
Context: func(v ...interface{}) interface{} {
Context: func(args ...interface{}) interface{} {
// Handle overlapping "time" namespace and func.
//
// If no args are passed to `time`, assume namespace usage and
@@ -34,11 +34,11 @@ func init() {
//
// If args are passed, call AsTime().
if len(v) == 0 {
if len(args) == 0 {
return ctx
}
t, err := ctx.AsTime(v[0])
t, err := ctx.AsTime(args[0])
if err != nil {
return err
}

View File

@@ -34,5 +34,5 @@ func TestInit(t *testing.T) {
}
require.True(t, found)
require.IsType(t, &Namespace{}, ns.Context.(func(v ...interface{}) interface{})())
require.IsType(t, &Namespace{}, ns.Context())
}