mirror of
https://github.com/jsiebens/ionscale.git
synced 2026-03-31 15:07:49 +01:00
5ad89ff02f
Signed-off-by: Johan Siebens <johan.siebens@gmail.com>
24 lines
443 B
Go
24 lines
443 B
Go
package templates
|
|
|
|
import (
|
|
"embed"
|
|
"github.com/labstack/echo/v4"
|
|
"html/template"
|
|
"io"
|
|
)
|
|
|
|
//go:embed *.html
|
|
var fs embed.FS
|
|
|
|
func NewTemplates() *Template {
|
|
return &Template{templates: template.Must(template.ParseFS(fs, "*.html"))}
|
|
}
|
|
|
|
type Template struct {
|
|
templates *template.Template
|
|
}
|
|
|
|
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
|
|
return t.templates.ExecuteTemplate(w, name, data)
|
|
}
|