1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
diff --git a/internal/handler/templates/functions.go b/internal/handler/templates/functions.go
index 8d33a7f3f885ed2495789ccd495a823a2dd22960..756e3474675972b22002f5f16239dc20cda12c14 100644
--- a/internal/handler/templates/functions.go
+++ b/internal/handler/templates/functions.go
@@ -1,11 +1,18 @@
package templates
import (
+ "html/template"
"sort"
"strings"
"git.sr.ht/~mpldr/gogit/internal/types"
)
+
+var functions = template.FuncMap{
+ "toCategoryMap": toCategoryMap,
+ "commitTitle": commitTitle,
+ "shorten": shorten,
+}
type ReposByCategory struct {
Category string
diff --git a/internal/handler/templates/parse.go b/internal/handler/templates/parse.go
index efd38554edd296aebf7c57adbe498e0529e90386..f52ee0fff9122b3c80e5df399b0f07bb9024fb01 100644
--- a/internal/handler/templates/parse.go
+++ b/internal/handler/templates/parse.go
@@ -26,11 +26,7 @@ slog.Error("failed to read template file", "path", path, "error", err)
continue
}
t := template.New(name)
- t.Funcs(template.FuncMap{
- "toCategoryMap": toCategoryMap,
- "commitTitle": commitTitle,
- "shorten": shorten,
- })
+ t.Funcs(functions)
if *tmpl, err = t.Parse(string(content)); err != nil {
slog.Error("failed to parse template", "name", name, "error", err)
continue
@@ -42,4 +38,5 @@
var templateMapping = map[string]**template.Template{
"index": &indexTmpl,
"overview": &overviewTmpl,
+ "commit": &commitTmpl,
}
|