feat/user-templates (#9)
All checks were successful
Go / build (push) Successful in 14s

feat: user templates
This commit was merged in pull request #9.
This commit is contained in:
2025-12-03 21:27:46 +01:00
parent acaece2659
commit 9a5ea229bf
19 changed files with 584 additions and 343 deletions

View File

@@ -9,15 +9,16 @@ import (
"time"
)
//go:embed assets/template.html
var htmlTemplate string
//go:embed assets/style.css
var style template.CSS
//go:embed assets/tailwind.js
var tailwind template.JS
type tmpler struct {
Report
Style template.CSS
Tailwind template.JS
Style template.CSS
}
func (r Report) ToHTML() (html string, err error) {
@@ -29,11 +30,11 @@ func (r Report) ToHTML() (html string, err error) {
"time": fmtDateTime,
"date": fmtDate,
"duration": fmtDuration,
}).Parse(htmlTemplate))
}).Parse(r.template))
buf := new(bytes.Buffer)
err = tmpl.Execute(buf, tmpler{r, style})
err = tmpl.Execute(buf, tmpler{r, tailwind, style})
if err != nil {
return html, err
}