Skip to content

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.

Example:

go
{{- define "HelloWorld" }}
{{- return (printf "Hello, %s!" .Data) }}
{{- end }}

{{ module.Export "HelloWorld" }}