module.Export
Export registers a function to allow it to be called by other templates.
This is only able to be called in library templates and the function's name must start with a capital letter. Function names are also only eligible to be exported once, if a function is exported twice the second call will be a runtime error.
The second argument to "module.Export" controls what "stencil", "file" and other template-scoped functions target. Valid options are "caller" or "function":
Note: The default of "function" will be changed to "caller" in v3.
Example:
go
{{- define "HelloWorld" }}
{{- return (printf "Hello, %s!" .Data) }}
{{- end }}
{{ module.Export "HelloWorld" }}Or:
go
{{ module.Export "HelloWorld" "caller" }}