diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-02-25 09:24:59 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-02-25 19:53:18 +0100 |
commit | ce524d0b5ebaef05d29fa368465f31358f26dcda (patch) | |
tree | e5df54a5deeefacbff4916d3619f85c2cb341b01 /resources/resource_transformers | |
parent | 2662faf61ff0240be1ee0d6c496b6b4a6ed55fb4 (diff) | |
download | hugo-ce524d0b5ebaef05d29fa368465f31358f26dcda.tar.gz hugo-ce524d0b5ebaef05d29fa368465f31358f26dcda.zip |
Add a page template func
Fixes #9339
Diffstat (limited to 'resources/resource_transformers')
-rw-r--r-- | resources/resource_transformers/templates/execute_as_template.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/resources/resource_transformers/templates/execute_as_template.go b/resources/resource_transformers/templates/execute_as_template.go index 5fe4230f1..4d4aba396 100644 --- a/resources/resource_transformers/templates/execute_as_template.go +++ b/resources/resource_transformers/templates/execute_as_template.go @@ -15,6 +15,7 @@ package templates import ( + "context" "fmt" "github.com/gohugoio/hugo/helpers" @@ -61,11 +62,11 @@ func (t *executeAsTemplateTransform) Transform(ctx *resources.ResourceTransforma ctx.OutPath = t.targetPath - return t.t.Tmpl().Execute(templ, ctx.To, t.data) + return t.t.Tmpl().ExecuteWithContext(ctx.Ctx, templ, ctx.To, t.data) } -func (c *Client) ExecuteAsTemplate(res resources.ResourceTransformer, targetPath string, data any) (resource.Resource, error) { - return res.Transform(&executeAsTemplateTransform{ +func (c *Client) ExecuteAsTemplate(ctx context.Context, res resources.ResourceTransformer, targetPath string, data any) (resource.Resource, error) { + return res.TransformWithContext(ctx, &executeAsTemplateTransform{ rs: c.rs, targetPath: helpers.ToSlashTrimLeading(targetPath), t: c.t, |