Changed the templating engine to a custom one. First bugged working example

This commit is contained in:
Jonas Hahn
2025-08-23 10:43:06 +02:00
parent 19e4834a9e
commit c9a3196ccb
15 changed files with 215 additions and 125 deletions

View File

@@ -4,11 +4,8 @@ import (
"crypto/rand"
"encoding/hex"
"errors"
"log"
"strings"
"time"
"github.com/gin-gonic/gin"
)
func mustRandToken(n int) string {
@@ -118,15 +115,9 @@ func fmtSscanf(s, _ string, a *int) (int, error) {
return 1, nil
}
func render(c *gin.Context, name string, data ctxData) {
u := getSessionUser(c)
if data == nil {
data = ctxData{}
}
log.Println("tpl error:", name)
data["CurrentUser"] = u
if err := tpl.ExecuteTemplate(c.Writer, name, data); err != nil {
log.Println("tpl error:", err)
c.Status(500)
func stripAfterDot(s string) string {
if idx := strings.Index(s, "."); idx != -1 {
return s[:idx]
}
return s
}