summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/templates/tplcontext.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/templates/tplcontext.go')
-rw-r--r--modules/caddyhttp/templates/tplcontext.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/caddyhttp/templates/tplcontext.go b/modules/caddyhttp/templates/tplcontext.go
index 4f3cbf5..7843455 100644
--- a/modules/caddyhttp/templates/tplcontext.go
+++ b/modules/caddyhttp/templates/tplcontext.go
@@ -40,10 +40,11 @@ import (
// TemplateContext is the TemplateContext with which HTTP templates are executed.
type TemplateContext struct {
- Root http.FileSystem
- Req *http.Request
- Args []interface{} // defined by arguments to funcInclude
- RespHeader WrappedHeader
+ Root http.FileSystem
+ Req *http.Request
+ Args []interface{} // defined by arguments to funcInclude
+ RespHeader WrappedHeader
+ CustomFuncs []template.FuncMap // functions added by plugins
config *Templates
tpl *template.Template
@@ -62,6 +63,11 @@ func (c *TemplateContext) NewTemplate(tplName string) *template.Template {
// add sprig library
c.tpl.Funcs(sprigFuncMap)
+ // add all custom functions
+ for _, funcMap := range c.CustomFuncs {
+ c.tpl.Funcs(funcMap)
+ }
+
// add our own library
c.tpl.Funcs(template.FuncMap{
"include": c.funcInclude,