mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Handle rebuilds when resources passed to transform.Unmarshal etc. changes
Fixes #12065
This commit is contained in:
@@ -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")
|
||||
|
Reference in New Issue
Block a user