@@ -46,6 +46,10 @@ and message `HTTPError.Message`.
4646
4747Enables debug mode.
4848
49+ ### Disable colored log
50+
51+ ` Echo.DisableColoredLog() `
52+
4953## Routing
5054
5155Echo's router is [ fast, optimized] ( https://github.com/labstack/echo#benchmark ) and
@@ -299,30 +303,90 @@ $ curl -d "name=joe" http://localhost:1323/users
299303
300304## Response
301305
306+ ### Template
307+
308+ ``` go
309+ Context.Render (code int , name string , data interface {}) error
310+ ```
311+ Renders a template with data and sends a text/html response with status code. Templates
312+ can be registered using ` Echo.SetRenderer() ` , allowing us to use any templating engine.
313+ Below is an example using Go ` html/template `
314+
315+ Implement ` echo.Render `
316+
317+ ``` go
318+ Template struct {
319+ templates *template.Template
320+ }
321+
322+ func (t *Template ) Render (w io .Writer , name string , data interface {}) error {
323+ return t.templates .ExecuteTemplate (w, name, data)
324+ }
325+ ```
326+
327+ Pre-compile templates
328+
329+ ``` go
330+ t := &Template{
331+ templates: template.Must (template.ParseGlob (" public/views/*.html" )),
332+ }
333+ ```
334+
335+ Register templates
336+
337+ ``` go
338+ e := echo.New ()
339+ e.SetRenderer (t)
340+ e.Get (" /hello" , Hello )
341+ ```
342+
343+ Template ` public/views/hello.html `
344+
345+ ``` html
346+ {{define "hello"}}Hello, {{.}}!{{end}}
347+
348+ ```
349+
350+ Handler
351+
352+ ``` go
353+ func Hello (c *echo .Context ) error {
354+ return c.Render (http.StatusOK , " hello" , " World" )
355+ }
356+ ```
357+
302358### JSON
303359
304360``` go
305- context .JSON (code int , v interface {}) error
361+ Context .JSON (code int , v interface {}) error
306362```
307363
308364Sends a JSON HTTP response with status code.
309365
310- ### String
366+ ### XML
311367
312368``` go
313- context. String (code int , s string ) error
369+ Context. XML (code int , v interface {} ) error
314370```
315371
316- Sends a text/plain HTTP response with status code.
372+ Sends an XML HTTP response with status code.
317373
318374### HTML
319375
320376``` go
321- func ( c * Context ) HTML (code int , html string ) error
377+ Context. HTML (code int , html string ) error
322378```
323379
324380Sends an HTML HTTP response with status code.
325381
382+ ### String
383+
384+ ``` go
385+ Context.String (code int , s string ) error
386+ ```
387+
388+ Sends a text/plain HTTP response with status code.
389+
326390### Static files
327391
328392` Echo.Static(path, root string) ` serves static files. For example, code below serves
0 commit comments