parent
c4e53afdf1
commit
abd9218561
19 changed files with 242 additions and 176 deletions
10
src/tmpl.go
10
src/tmpl.go
|
|
@ -12,10 +12,10 @@ var TMPL map[string][]byte
|
|||
func generateTmpl() {
|
||||
files, _ := filepath.Glob("html/*.html")
|
||||
re := regexp.MustCompile("html/(.+).html")
|
||||
names := make([]string, len(files))
|
||||
pages := make([]string, len(files))
|
||||
|
||||
for i, f := range files {
|
||||
names[i] = re.FindStringSubmatch(f)[1]
|
||||
pages[i] = re.FindStringSubmatch(f)[1]
|
||||
}
|
||||
TMPL = make(map[string][]byte, len(files))
|
||||
for i, f := range files {
|
||||
|
|
@ -23,9 +23,9 @@ func generateTmpl() {
|
|||
t, _ := template.ParseFiles(f)
|
||||
t.ParseGlob("tmpl/*.tmpl")
|
||||
t.Execute(b, map[string]any{
|
||||
"name": names[i],
|
||||
"names": names,
|
||||
"page": pages[i],
|
||||
"pages": pages,
|
||||
})
|
||||
TMPL[names[i]] = b.Bytes()
|
||||
TMPL[pages[i]] = b.Bytes()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue