package main import ( "html/template" "io" "github.com/gobuffalo/packr" "github.com/labstack/echo/v4" ) // Template struct type Template struct{} // Render template saved in packr func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error { box := packr.NewBox("./ui") tmpl, err := template.New(name).Parse(box.String("index.html")) if err != nil { panic(err) } tmpl, err = tmpl.Parse(box.String(name)) if err != nil { panic(err) } response := tmpl.ExecuteTemplate(w, name, data) return response }