Changed the templating engine to a custom one. First bugged working example
This commit is contained in:
17
src/utils.go
17
src/utils.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user