Templates within Echo

The Echo framework does provide a facility for custom rendering which is based on the echo.Renderer interface. This interface stipulates that implementations have a method Render which will perform the rendering of data. With this convention, we are able to take what we learned about Go templates and apply those templates to implement a custom echo.Renderer that is capable of rendering HTML templates back to the caller. The following is a very minimal example of an echo.Renderer implementation that we have implemented in $GOPATH/src/github.com/PacktPublishing/Echo-Essentials/chapter8/handlers/reminder.go:

type CustomTemplate struct { *template.Template } func (ct *CustomTemplate) Render(w io.Writer, name string, data ...

Get Echo Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.