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