mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-19 10:03:02 -06:00
provide noescape function for templates
This commit is contained in:
parent
adf4712b39
commit
89c369f21e
3 changed files with 22 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ package web
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -84,6 +85,10 @@ func (m *Module) NotFoundHandler(c *gin.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func noescape(str string) template.HTML {
|
||||
return template.HTML(str)
|
||||
}
|
||||
|
||||
// Route satisfies the RESTAPIModule interface
|
||||
func (m *Module) Route(s router.Router) error {
|
||||
|
||||
|
|
@ -101,5 +106,13 @@ func (m *Module) Route(s router.Router) error {
|
|||
// 404 handler
|
||||
s.AttachNoRouteHandler(m.NotFoundHandler)
|
||||
|
||||
s.SetTemplateFuncMap(template.FuncMap{
|
||||
"noescape": noescape,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("error setting router FuncMap: %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue