summaryrefslogtreecommitdiffhomepage
path: root/src/templates.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/templates.go')
-rw-r--r--src/templates.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/templates.go b/src/templates.go
index 5a4d7c5..2cee22e 100644
--- a/src/templates.go
+++ b/src/templates.go
@@ -2,9 +2,9 @@ package src
import (
"embed"
+ "fmt"
"html/template"
"log"
- "os"
"strings"
"git.thomasvoss.com/euro-cash.eu/src/mintage"
@@ -22,11 +22,12 @@ var (
templateFS embed.FS
notFoundTmpl = buildTemplate("-404")
errorTmpl = buildTemplate("-error")
- templates map[string]*template.Template
- funcmap = map[string]any{
+ templates map[string]*template.Template
+ funcmap = map[string]any{
"denoms": denoms,
"locales": locales,
"safe": asHTML,
+ "sprintf": fmt.Sprintf,
"strToCtype": strToCtype,
"toUpper": strings.ToUpper,
"tuple": templateMakeTuple,
@@ -34,19 +35,18 @@ var (
)
func init() {
- ents, err := os.ReadDir("src/templates")
+ ents, err := templateFS.ReadDir("templates")
if err != nil {
log.Fatalln(err)
}
templates = make(map[string]*template.Template, len(ents))
for _, e := range ents {
path := "/"
- name, _ := strings.CutSuffix(e.Name(), ".html.tmpl")
+ name := strings.TrimSuffix(e.Name(), ".html.tmpl")
switch {
case name[0] == '-':
continue
- case name == "index":
- default:
+ case name != "index":
path += strings.ReplaceAll(name, "-", "/")
}
templates[path] = buildTemplate(name)