// Package render wires Go html/template page shells into Echo. The server emits // the page shell and declares web components; the components fetch their own // data (AGENT.md §1.1, §2). package render import ( "html/template" "io" "path/filepath" "github.com/labstack/echo/v4" ) // Templates implements echo.Renderer over the templates in a directory. type Templates struct { tmpl *template.Template } // New parses every *.html file in dir. func New(dir string) (*Templates, error) { t, err := template.ParseGlob(filepath.Join(dir, "*.html")) if err != nil { return nil, err } return &Templates{tmpl: t}, nil } // Render satisfies echo.Renderer. func (t *Templates) Render(w io.Writer, name string, data any, _ echo.Context) error { return t.tmpl.ExecuteTemplate(w, name, data) }