mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-02 01:47:03 +00:00
parent
4d221ce468
commit
6c70e1f22f
53 changed files with 122 additions and 65 deletions
hugolib
tpl
cast
collections
compare
crypto
data
debug
encoding
fmt
hugo
images
inflect
internal
js
lang
math
openapi/openapi3
os
partials
path
reflect
resources
safe
site
strings
templates
time
transform
urls
|
@ -203,3 +203,14 @@ timeZone = "America/LosAngeles" # Should be America/Los_Angeles
|
|||
b.Assert(err, qt.Not(qt.IsNil))
|
||||
b.Assert(err.Error(), qt.Contains, `failed to load config: invalid timeZone for language "en": unknown time zone America/LosAngeles`)
|
||||
}
|
||||
|
||||
// Issue 8835
|
||||
func TestTimeOnError(t *testing.T) {
|
||||
b := newTestSitesBuilder(t)
|
||||
|
||||
b.WithTemplates("index.html", `time: {{ time "2020-10-20" "invalid-timezone" }}`)
|
||||
b.WithContent("p1.md", "")
|
||||
|
||||
b.Assert(b.BuildE(BuildCfg{}), qt.Not(qt.IsNil))
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.ToInt,
|
||||
|
|
|
@ -37,5 +37,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.After,
|
||||
|
|
|
@ -37,5 +37,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Default,
|
||||
|
|
|
@ -36,5 +36,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.MD5,
|
||||
|
|
|
@ -36,5 +36,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.GetCSV,
|
||||
|
|
|
@ -41,5 +41,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Dump,
|
||||
|
|
|
@ -38,5 +38,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Base64Decode,
|
||||
|
|
|
@ -36,5 +36,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Print,
|
||||
|
|
|
@ -38,5 +38,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return h },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return h, nil },
|
||||
}
|
||||
|
||||
// We just add the Hugo struct as the namespace here. No method mappings.
|
||||
|
|
|
@ -43,5 +43,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, s.Hugo())
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, s.Hugo())
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Config,
|
||||
|
|
|
@ -36,5 +36,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Humanize,
|
||||
|
|
|
@ -37,5 +37,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
return ns
|
||||
|
|
|
@ -27,7 +27,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Translate,
|
||||
|
|
|
@ -42,5 +42,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Add,
|
||||
|
|
|
@ -36,5 +36,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Unmarshal,
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Getenv,
|
||||
|
|
|
@ -36,5 +36,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Include,
|
||||
|
|
|
@ -40,5 +40,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Split,
|
||||
|
|
|
@ -37,5 +37,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.IsMap,
|
||||
|
|
|
@ -37,5 +37,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Get,
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.CSS,
|
||||
|
|
|
@ -37,5 +37,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func init() {
|
|||
s := d.Site
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return s },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return s, nil },
|
||||
}
|
||||
|
||||
if s == nil {
|
||||
|
|
|
@ -43,5 +43,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, s)
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, s)
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Chomp,
|
||||
|
|
|
@ -39,5 +39,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Exists,
|
||||
|
|
|
@ -36,5 +36,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
package time
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/langs"
|
||||
"github.com/gohugoio/hugo/tpl/internal"
|
||||
|
@ -30,7 +32,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} {
|
||||
Context: func(args ...interface{}) (interface{}, error) {
|
||||
// Handle overlapping "time" namespace and func.
|
||||
//
|
||||
// If no args are passed to `time`, assume namespace usage and
|
||||
|
@ -40,23 +42,15 @@ func init() {
|
|||
|
||||
switch len(args) {
|
||||
case 0:
|
||||
return ctx
|
||||
return ctx, nil
|
||||
case 1:
|
||||
t, err := ctx.AsTime(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return t
|
||||
return ctx.AsTime(args[0])
|
||||
case 2:
|
||||
t, err := ctx.AsTime(args[0], args[1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return t
|
||||
return ctx.AsTime(args[0], args[1])
|
||||
|
||||
// 3 or more arguments. Currently not supported.
|
||||
default:
|
||||
return "Invalid arguments supplied to `time`. Refer to time documentation: https://gohugo.io/functions/time/"
|
||||
return nil, errors.New("Invalid arguments supplied to `time`. Refer to time documentation: https://gohugo.io/functions/time/")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -42,5 +42,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.Emojify,
|
||||
|
|
|
@ -36,5 +36,7 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
|||
|
||||
ns := &internal.TemplateFuncsNamespace{
|
||||
Name: name,
|
||||
Context: func(args ...interface{}) interface{} { return ctx },
|
||||
Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
|
||||
}
|
||||
|
||||
ns.AddMethodMapping(ctx.AbsURL,
|
||||
|
|
|
@ -38,5 +38,8 @@ func TestInit(t *testing.T) {
|
|||
}
|
||||
|
||||
c.Assert(found, qt.Equals, true)
|
||||
c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
|
||||
ctx, err := ns.Context()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(ctx, hqt.IsSameType, &Namespace{})
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue