aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/templates/tplcontext.go
diff options
context:
space:
mode:
authordeneb <[email protected]>2024-05-18 20:55:36 +0200
committerGitHub <[email protected]>2024-05-18 12:55:36 -0600
commitf98f449f05c251da2b25fe96ffb73319b4a7af76 (patch)
treeedf5b73b310cd24f8a4b102a140c02ef7b45c710 /modules/caddyhttp/templates/tplcontext.go
parente66040a6f0b384d9cebd38a78f746f08f4cb22c1 (diff)
downloadcaddy-f98f449f05c251da2b25fe96ffb73319b4a7af76.tar.gz
caddy-f98f449f05c251da2b25fe96ffb73319b4a7af76.zip
templates: Add `pathEscape` template function and use it in file browser (#6278)
* use url.PathEscape in file-server browse template - add `pathEscape` to c.tpl.Funcs, using `url.PathEscape` - use `pathEscape` in browse.html in place of `replace` * document `pathEscape` * Remove unnecessary pipe of img src to `html`
Diffstat (limited to 'modules/caddyhttp/templates/tplcontext.go')
-rw-r--r--modules/caddyhttp/templates/tplcontext.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/modules/caddyhttp/templates/tplcontext.go b/modules/caddyhttp/templates/tplcontext.go
index 4c7c86e13..2324586be 100644
--- a/modules/caddyhttp/templates/tplcontext.go
+++ b/modules/caddyhttp/templates/tplcontext.go
@@ -21,6 +21,7 @@ import (
"io/fs"
"net"
"net/http"
+ "net/url"
"os"
"path"
"reflect"
@@ -91,6 +92,7 @@ func (c *TemplateContext) NewTemplate(tplName string) *template.Template {
"httpError": c.funcHTTPError,
"humanize": c.funcHumanize,
"maybe": c.funcMaybe,
+ "pathEscape": url.PathEscape,
})
return c.tpl
}