// Render renders a template document
Render renders a template document
// Render renders a template document
func (t *TemplateRenderer) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
	log.Ctx(c.Request().Context()).Debug().Str("name", name).Msg("Render")
	tmpl, ok := t.templates[name]
	if !ok {
		log.Ctx(c.Request().Context()).Error().Str("name", name).Msg("template not found")
		return c.NoContent(http.StatusInternalServerError)
	}
	execName := tmpl.name
	if tmpl.layout != "" {
		execName = tmpl.layout
	}
	start := time.Now()
	err := tmpl.template.ExecuteTemplate(w, execName, data)
	if err != nil {
		log.Ctx(c.Request().Context()).Error().Err(err).Str("name", tmpl.name).Str("layout", tmpl.layout).Msg("render template failed")
		return err
	}
	log.Ctx(c.Request().Context()).Debug().Str("name", tmpl.name).Str("dur", time.Since(start).String()).Str("layout", tmpl.layout).Msg("execute template")
	return nil
}
func ( t * TemplateRenderer ) Render ( w io . Writer , name string , data interface { } , c echo . Context ) error { log . Ctx ( c . Request ( ) . Context ( ) ) . Debug ( ) . Str ( " " , name ) . Msg ( " " ) tmpl , ok := t . templates [ name ] if ! ok { log . Ctx ( c . Request ( ) . Context ( ) ) . Error ( ) . Str ( " " , name ) . Msg ( " " ) return c . NoContent ( http . StatusInternalServerError ) } execName := tmpl . name if tmpl . layout != " " { execName = tmpl . layout } start := time . Now ( ) err := tmpl . template . ExecuteTemplate ( w , execName , data ) if err != nil { log . Ctx ( c . Request ( ) . Context ( ) ) . Error ( ) . Err ( err ) . Str ( " " , tmpl . name ) . Str ( " " , tmpl . layout ) . Msg ( " " ) return err } log . Ctx ( c . Request ( ) . Context ( ) ) . Debug ( ) . Str ( " " , tmpl . name ) . Str ( " " , time . Since ( start ) . String ( ) ) . Str ( " " , tmpl . layout ) . Msg ( " " ) return nil }
Render renders a template document
Render renders a template document
// use the name of the template, or layout if it exists