aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/tplimpl/template_funcs.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-02-19 11:32:28 +0100
committerBjørn Erik Pedersen <[email protected]>2024-02-19 14:50:23 +0100
commit5dbc29dc6c02d8d1e2f0deef7be6a58609b78d5d (patch)
tree12af34b1640473cbe828a55f945837c652891da7 /tpl/tplimpl/template_funcs.go
parent5ada27bf65935b030c84a7cc1257c66f8eedfd84 (diff)
downloadhugo-5dbc29dc6c02d8d1e2f0deef7be6a58609b78d5d.tar.gz
hugo-5dbc29dc6c02d8d1e2f0deef7be6a58609b78d5d.zip
Handle rebuilds when resources passed to transform.Unmarshal etc. changes
Fixes #12065
Diffstat (limited to 'tpl/tplimpl/template_funcs.go')
-rw-r--r--tpl/tplimpl/template_funcs.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/tpl/tplimpl/template_funcs.go b/tpl/tplimpl/template_funcs.go
index 8997c83d6..9d14b9e56 100644
--- a/tpl/tplimpl/template_funcs.go
+++ b/tpl/tplimpl/template_funcs.go
@@ -150,6 +150,30 @@ func (t *templateExecHelper) GetMethod(ctx context.Context, tmpl texttemplate.Pr
return fn, zero
}
+func (t *templateExecHelper) OnCalled(ctx context.Context, tmpl texttemplate.Preparer, name string, args []reflect.Value, result reflect.Value) {
+ if !t.running {
+ return
+ }
+
+ // This switch is mostly for speed.
+ switch name {
+ case "Unmarshal":
+ default:
+ return
+ }
+ idm := tpl.Context.GetDependencyManagerInCurrentScope(ctx)
+ if idm == nil {
+ return
+ }
+
+ for _, arg := range args {
+ identity.WalkIdentitiesShallow(arg.Interface(), func(level int, id identity.Identity) bool {
+ idm.AddIdentity(id)
+ return false
+ })
+ }
+}
+
func (t *templateExecHelper) trackDependencies(ctx context.Context, tmpl texttemplate.Preparer, name string, receiver reflect.Value) context.Context {
if tmpl == nil {
panic("must provide a template")