From f05b2555117b631eba0ec55fc1ac6d4c9abb8605 Mon Sep 17 00:00:00 2001 From: f0x52 Date: Tue, 13 Jul 2021 16:05:03 +0200 Subject: Noescape (#88) * disable html escaping for short description * provide noescape function for templates * move template functions before template loading * go fmt * linter fixes --- internal/router/template.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'internal/router/template.go') diff --git a/internal/router/template.go b/internal/router/template.go index cd1eb11db..787ade799 100644 --- a/internal/router/template.go +++ b/internal/router/template.go @@ -2,6 +2,7 @@ package router import ( "fmt" + "html/template" "os" "path/filepath" @@ -21,3 +22,13 @@ func loadTemplates(cfg *config.Config, engine *gin.Engine) error { engine.LoadHTMLGlob(tmPath) return nil } + +func noescape(str string) template.HTML { + return template.HTML(str) +} + +func loadTemplateFunctions(engine *gin.Engine) { + engine.SetFuncMap(template.FuncMap{ + "noescape": noescape, + }) +} -- cgit v1.2.3