mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
@@ -48,7 +48,7 @@ type ExecHelper interface {
|
||||
|
||||
// Executer executes a given template.
|
||||
type Executer interface {
|
||||
ExecuteWithContext(ctx context.Context, p Preparer, wr io.Writer, data interface{}) error
|
||||
ExecuteWithContext(ctx context.Context, p Preparer, wr io.Writer, data any) error
|
||||
}
|
||||
|
||||
type executer struct {
|
||||
@@ -72,7 +72,7 @@ const (
|
||||
)
|
||||
|
||||
// Note: The context is currently not fully implemeted in Hugo. This is a work in progress.
|
||||
func (t *executer) ExecuteWithContext(ctx context.Context, p Preparer, wr io.Writer, data interface{}) error {
|
||||
func (t *executer) ExecuteWithContext(ctx context.Context, p Preparer, wr io.Writer, data any) error {
|
||||
tmpl, err := p.Prepare()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -101,7 +101,7 @@ func (t *executer) ExecuteWithContext(ctx context.Context, p Preparer, wr io.Wri
|
||||
return tmpl.executeWithState(state, value)
|
||||
}
|
||||
|
||||
func (t *executer) Execute(p Preparer, wr io.Writer, data interface{}) error {
|
||||
func (t *executer) Execute(p Preparer, wr io.Writer, data any) error {
|
||||
tmpl, err := p.Prepare()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// We allow string or a map as the first argument in some cases.
|
||||
func ResolveIfFirstArgIsString(args []interface{}) (resources.ResourceTransformer, string, bool) {
|
||||
func ResolveIfFirstArgIsString(args []any) (resources.ResourceTransformer, string, bool) {
|
||||
if len(args) != 2 {
|
||||
return nil, "", false
|
||||
}
|
||||
@@ -41,7 +41,7 @@ func ResolveIfFirstArgIsString(args []interface{}) (resources.ResourceTransforme
|
||||
}
|
||||
|
||||
// This roundabout way of doing it is needed to get both pipeline behaviour and options as arguments.
|
||||
func ResolveArgs(args []interface{}) (resources.ResourceTransformer, map[string]interface{}, error) {
|
||||
func ResolveArgs(args []any) (resources.ResourceTransformer, map[string]any, error) {
|
||||
if len(args) == 0 {
|
||||
return nil, nil, errors.New("no Resource provided in transformation")
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func ResolveArgs(args []interface{}) (resources.ResourceTransformer, map[string]
|
||||
|
||||
r, ok := args[1].(resources.ResourceTransformer)
|
||||
if !ok {
|
||||
if _, ok := args[1].(map[string]interface{}); !ok {
|
||||
if _, ok := args[1].(map[string]any); !ok {
|
||||
return nil, nil, fmt.Errorf("no Resource provided in transformation")
|
||||
}
|
||||
return nil, nil, fmt.Errorf("type %T not supported in Resource transformations", args[0])
|
||||
|
@@ -49,7 +49,7 @@ type TemplateFuncsNamespace struct {
|
||||
Name string
|
||||
|
||||
// This is the method receiver.
|
||||
Context func(v ...interface{}) (interface{}, error)
|
||||
Context func(v ...any) (any, error)
|
||||
|
||||
// Additional info, aliases and examples, per method name.
|
||||
MethodMappings map[string]TemplateFuncMethodMapping
|
||||
@@ -59,7 +59,7 @@ type TemplateFuncsNamespace struct {
|
||||
type TemplateFuncsNamespaces []*TemplateFuncsNamespace
|
||||
|
||||
// AddMethodMapping adds a method to a template function namespace.
|
||||
func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string) {
|
||||
func (t *TemplateFuncsNamespace) AddMethodMapping(m any, aliases []string, examples [][2]string) {
|
||||
if t.MethodMappings == nil {
|
||||
t.MethodMappings = make(map[string]TemplateFuncMethodMapping)
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []strin
|
||||
// TemplateFuncMethodMapping represents a mapping of functions to methods for a
|
||||
// given namespace.
|
||||
type TemplateFuncMethodMapping struct {
|
||||
Method interface{}
|
||||
Method any
|
||||
|
||||
// Any template funcs aliases. This is mainly motivated by keeping
|
||||
// backwards compatibility, but some new template funcs may also make
|
||||
@@ -104,7 +104,7 @@ type TemplateFuncMethodMapping struct {
|
||||
Examples [][2]string
|
||||
}
|
||||
|
||||
func methodToName(m interface{}) string {
|
||||
func methodToName(m any) string {
|
||||
name := runtime.FuncForPC(reflect.ValueOf(m).Pointer()).Name()
|
||||
name = filepath.Ext(name)
|
||||
name = strings.TrimPrefix(name, ".")
|
||||
|
Reference in New Issue
Block a user