MCPcopy Index your code
hub / github.com/unrolled/render / Render

Method Render

engine.go:96–116  ·  view source on GitHub ↗

Render a HTML response.

(w io.Writer, binding interface{})

Source from the content-addressed store, hash-verified

94
95// Render a HTML response.
96func (h HTML) Render(w io.Writer, binding interface{}) error {
97 var buf *bytes.Buffer
98 if h.bp != nil {
99 // If we have a bufferpool, allocate from it
100 buf = h.bp.Get()
101 defer h.bp.Put(buf)
102 }
103
104 err := h.Templates.ExecuteTemplate(buf, h.Name, binding)
105 if err != nil {
106 return err
107 }
108
109 if hw, ok := w.(http.ResponseWriter); ok {
110 h.Write(hw)
111 }
112
113 _, _ = buf.WriteTo(w)
114
115 return nil
116}
117
118// Render a JSON response.
119func (j JSON) Render(w io.Writer, v interface{}) error {

Callers

nothing calls this directly

Calls 3

WriteMethod · 0.80
GetMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected