commit 1624f0429fd566ac4905a12fa17c9f5cd4ec5b12
parent f2f9073ea76d21a544890fd01d3957a71fa6ecf3
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 19 Dec 2023 02:38:30 -0500
simple template
Diffstat:
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go
@@ -1031,6 +1031,12 @@ func Must[T any](v T, err error) T {
return v
}
+func Must1(err error) {
+ if err != nil {
+ panic(err)
+ }
+}
+
func ValidateRuneLength(str string, min, max int) bool {
return govalidator.RuneLength(str, strconv.Itoa(min), strconv.Itoa(max))
}
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -1759,10 +1759,12 @@ func buildActionsDiv(roomID RoomID) (html string) {
data := map[string]any{
"RoomID": roomID.String(),
}
+ return simpleTmpl(htmlTmpl, data)
+}
+
+func simpleTmpl(htmlTmpl string, data any) string {
var buf bytes.Buffer
- if err := utils.Must(template.New("").Parse(htmlTmpl)).Execute(&buf, data); err != nil {
- logrus.Error(err)
- }
+ utils.Must1(utils.Must(template.New("").Parse(htmlTmpl)).Execute(&buf, data))
return buf.String()
}