mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
@@ -15,11 +15,10 @@
|
||||
package resources
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/gohugoio/hugo/common/herrors"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
@@ -227,7 +226,6 @@ func (ns *Namespace) ByType(typ any) resource.Resources {
|
||||
//
|
||||
// See Match for a more complete explanation about the rules used.
|
||||
func (ns *Namespace) Match(pattern any) resource.Resources {
|
||||
defer herrors.Recover()
|
||||
patternStr, err := cast.ToStringE(pattern)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -283,7 +281,7 @@ func (ns *Namespace) FromString(targetPathIn, contentIn any) (resource.Resource,
|
||||
|
||||
// ExecuteAsTemplate creates a Resource from a Go template, parsed and executed with
|
||||
// the given data, and published to the relative target path.
|
||||
func (ns *Namespace) ExecuteAsTemplate(args ...any) (resource.Resource, error) {
|
||||
func (ns *Namespace) ExecuteAsTemplate(ctx context.Context, args ...any) (resource.Resource, error) {
|
||||
if len(args) != 3 {
|
||||
return nil, fmt.Errorf("must provide targetPath, the template data context and a Resource object")
|
||||
}
|
||||
@@ -298,7 +296,7 @@ func (ns *Namespace) ExecuteAsTemplate(args ...any) (resource.Resource, error) {
|
||||
return nil, fmt.Errorf("type %T not supported in Resource transformations", args[2])
|
||||
}
|
||||
|
||||
return ns.templatesClient.ExecuteAsTemplate(r, targetPath, data)
|
||||
return ns.templatesClient.ExecuteAsTemplate(ctx, r, targetPath, data)
|
||||
}
|
||||
|
||||
// Fingerprint transforms the given Resource with a MD5 hash of the content in
|
||||
|
Reference in New Issue
Block a user