This commit is contained in:
Victor Lacasse-Beaudoin 2024-12-30 17:30:37 -05:00
parent cc8c8ef967
commit cdb16a9b60
9 changed files with 212 additions and 50 deletions

View file

@ -4,7 +4,3 @@ import "embed"
//go:embed *.html
var htmlFS embed.FS
func HTMLFS() embed.FS {
return htmlFS
}

22
ui/render.go Normal file
View file

@ -0,0 +1,22 @@
package ui
import (
"io"
"text/template"
"github.com/labstack/echo/v4"
)
type Renderer struct {
templates *template.Template
}
func (t *Renderer) Render(w io.Writer, name string, data any, c echo.Context) error {
return t.templates.ExecuteTemplate(w, name, data)
}
func NewRenderer() *Renderer {
return &Renderer{
templates: template.Must(template.ParseFS(htmlFS, "*html")),
}
}