+Abkürzungen

This commit is contained in:
Simon Martens
2026-01-12 18:57:34 +01:00
parent 696f7fe087
commit 7d7637fe13
21 changed files with 465 additions and 204 deletions

View File

@@ -1,6 +1,7 @@
package functions
import (
"encoding/json"
"fmt"
"html/template"
"regexp"
@@ -19,6 +20,15 @@ func Safe(s string) template.HTML {
return template.HTML(s)
}
func SafeJS(s any) template.JS {
b, err := json.Marshal(s)
if err != nil {
return template.JS("{}")
}
return template.JS(b)
}
func ReplaceSlashParen(s string) string {
return strings.ReplaceAll(s, "/)", "<p>")
}