aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/templates.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/templates.go')
-rw-r--r--src/templates.go22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/templates.go b/src/templates.go
index a7d7f2a..a3bc52d 100644
--- a/src/templates.go
+++ b/src/templates.go
@@ -1,7 +1,6 @@
package app
import (
- "bytes"
"html/template"
"io/fs"
"log"
@@ -82,9 +81,10 @@ func buildTemplate(dir fs.FS, name string) *template.Template {
for i, s := range names {
names[i] = s + ".html.tmpl"
}
- t := template.New("-base.html.tmpl").Funcs(funcmap)
- t = t.Funcs(includeIfExists(t))
- return template.Must(t.ParseFS(dir, names[:]...))
+ return template.Must(template.
+ New("-base.html.tmpl").
+ Funcs(funcmap).
+ ParseFS(dir, names[:]...))
}
func asHTML(s string) template.HTML {
@@ -112,20 +112,6 @@ func templateMakeMap(args ...any) map[string]any {
return m
}
-func includeIfExists(tmpl *template.Template) template.FuncMap {
- return template.FuncMap{
- "includeIfExists": func(name string, data any) (template.HTML, error) {
- t := tmpl.Lookup(name)
- if t == nil {
- return "", nil
- }
- var buf bytes.Buffer
- err := t.Execute(&buf, data)
- return template.HTML(buf.String()), err
- },
- }
-}
-
func ifElse(b bool, x, y any) any {
if b {
return x