23 lines
403 B
Go
23 lines
403 B
Go
package handlers
|
|
|
|
import (
|
|
"html/template"
|
|
"io"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type TemplateRenderer struct {
|
|
tmpls *template.Template
|
|
}
|
|
|
|
var Renderer = &TemplateRenderer{tmpls: template.New("")}
|
|
|
|
func (t *TemplateRenderer) Render(w io.Writer, name string, data any, c echo.Context) error {
|
|
c.Logger().Debugf("rendering template %s", name)
|
|
|
|
tpl := getTmpl(name)
|
|
|
|
return tpl.Execute(w, data)
|
|
}
|