From d78429129f3970f4396cc4bc90bfc6cdd51063ca Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 13 Aug 2017 18:04:26 +1200 Subject: [PATCH] also use path escaping function for whole-template links --- WikiServer.go | 8 +++++++- pageTemplate.go | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/WikiServer.go b/WikiServer.go index 2c0eba6..8937aba 100644 --- a/WikiServer.go +++ b/WikiServer.go @@ -37,7 +37,13 @@ func NewWikiServer(opts *ServerOptions) (*WikiServer, error) { } } - tmpl, err := template.New("yatwiki/page").Parse(pageTemplate) + tmpl := template.New("yatwiki/page") + tmpl.Funcs(map[string]interface{}{ + "pathcomponent": func(s string) string { + return url.PathEscape(s) + }, + }) + _, err = tmpl.Parse(pageTemplate) if err != nil { return nil, err } diff --git a/pageTemplate.go b/pageTemplate.go index 72d46a1..11f5ba7 100644 --- a/pageTemplate.go +++ b/pageTemplate.go @@ -85,13 +85,13 @@ function els(e,s){ // no js exec in innerHTML
-
+
-
+
{{if .CurrentPageIsArticle }}
-
-
+
+
{{end}}