add app review system with validation pipeline and admin htmx UI

This commit is contained in:
2026-01-18 21:35:43 +01:00
parent cf9f42b66d
commit fbcb5c9543
11 changed files with 1516 additions and 9 deletions

View File

@@ -17,6 +17,28 @@ type Templates struct {
templates map[string]*template.Template
}
// Template helper functions
var templateFuncs = template.FuncMap{
"divFloat": func(a int64, b int) float64 {
return float64(a) / float64(b)
},
"add": func(a, b int) int {
return a + b
},
"sub": func(a, b int) int {
return a - b
},
"mul": func(a, b int) int {
return a * b
},
"min": func(a, b int) int {
if a < b {
return a
}
return b
},
}
// NewTemplates creates and parses all templates
func NewTemplates() (*Templates, error) {
t := &Templates{
@@ -47,7 +69,7 @@ func NewTemplates() (*Templates, error) {
files := append([]string{pageFile}, baseFiles...)
// Read and parse all files
tmpl := template.New(filepath.Base(pageFile))
tmpl := template.New(filepath.Base(pageFile)).Funcs(templateFuncs)
for _, file := range files {
content, err := templateFS.ReadFile(file)
if err != nil {
@@ -70,7 +92,7 @@ func NewTemplates() (*Templates, error) {
if err != nil {
return nil, err
}
tmpl, err := template.New(filepath.Base(partialFile)).Parse(string(content))
tmpl, err := template.New(filepath.Base(partialFile)).Funcs(templateFuncs).Parse(string(content))
if err != nil {
return nil, err
}