summaryrefslogtreecommitdiff
path: root/internal/router
diff options
context:
space:
mode:
Diffstat (limited to 'internal/router')
-rw-r--r--internal/router/router.go3
-rw-r--r--internal/router/template.go11
2 files changed, 14 insertions, 0 deletions
diff --git a/internal/router/router.go b/internal/router/router.go
index a77b7071e..87a84922c 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -126,6 +126,9 @@ func New(cfg *config.Config, db db.DB, logger *logrus.Logger) (Router, error) {
return nil, err
}
+ // set template functions
+ loadTemplateFunctions(engine)
+
// load templates onto the engine
if err := loadTemplates(cfg, engine); err != nil {
return nil, err
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,
+ })
+}