summaryrefslogtreecommitdiffstats
path: root/tpl/internal/go_templates/texttemplate
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/internal/go_templates/texttemplate')
-rw-r--r--tpl/internal/go_templates/texttemplate/hugo_template.go10
-rw-r--r--tpl/internal/go_templates/texttemplate/hugo_template_test.go3
2 files changed, 12 insertions, 1 deletions
diff --git a/tpl/internal/go_templates/texttemplate/hugo_template.go b/tpl/internal/go_templates/texttemplate/hugo_template.go
index 4db40ce82..276367a7c 100644
--- a/tpl/internal/go_templates/texttemplate/hugo_template.go
+++ b/tpl/internal/go_templates/texttemplate/hugo_template.go
@@ -44,6 +44,7 @@ type ExecHelper interface {
GetFunc(ctx context.Context, tmpl Preparer, name string) (reflect.Value, reflect.Value, bool)
GetMethod(ctx context.Context, tmpl Preparer, receiver reflect.Value, name string) (method reflect.Value, firstArg reflect.Value)
GetMapValue(ctx context.Context, tmpl Preparer, receiver, key reflect.Value) (reflect.Value, bool)
+ OnCalled(ctx context.Context, tmpl Preparer, name string, args []reflect.Value, result reflect.Value)
}
// Executer executes a given template.
@@ -356,7 +357,14 @@ func (s *state) evalCall(dot, fun reflect.Value, isBuiltin bool, node parse.Node
s.at(node)
s.errorf("error calling %s: %w", name, err)
}
- return unwrap(v)
+ vv := unwrap(v)
+
+ // Added for Hugo
+ if s.helper != nil {
+ s.helper.OnCalled(s.ctx, s.prep, name, argv, vv)
+ }
+
+ return vv
}
func isTrue(val reflect.Value) (truth, ok bool) {
diff --git a/tpl/internal/go_templates/texttemplate/hugo_template_test.go b/tpl/internal/go_templates/texttemplate/hugo_template_test.go
index c68b747dd..920d96fac 100644
--- a/tpl/internal/go_templates/texttemplate/hugo_template_test.go
+++ b/tpl/internal/go_templates/texttemplate/hugo_template_test.go
@@ -64,6 +64,9 @@ func (e *execHelper) GetMethod(ctx context.Context, tmpl Preparer, receiver refl
return m, reflect.ValueOf("v2")
}
+func (e *execHelper) OnCalled(ctx context.Context, tmpl Preparer, name string, args []reflect.Value, returnValue reflect.Value) {
+}
+
func TestTemplateExecutor(t *testing.T) {
c := qt.New(t)