Documentation
¶
Index ¶
- Constants
- type BufferPool
- type Grender
- func (r *Grender) HTML(w http.ResponseWriter, statusCode int, templateName string, data interface{}) error
- func (r *Grender) JSON(w http.ResponseWriter, statusCode int, data interface{}) error
- func (r *Grender) Text(w http.ResponseWriter, statusCode int, data string) error
- func (r *Grender) XML(w http.ResponseWriter, statusCode int, data interface{}) error
- type Options
Constants ¶
View Source
const ( // ContentHTML HTTP header value for HTML data ContentHTML = "text/html" // ContentJSON HTTP header value for JSON data ContentJSON = "application/json" // ContentType HTTP header name for defining the content type ContentType = "Content-Type" // ContentText header value for Text data. ContentText = "text/plain" // ContentXML header value for XML data. ContentXML = "text/xml" // DefaultCharset for when no specific Charset Options was given DefaultCharset = "UTF-8" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool implements a pool of bytes.Buffers in the form of a bounded channel. Pulled from the github.com/oxtoacart/bpool package (Apache licensed).
func NewBufferPool ¶
func NewBufferPool(size int) (bp *BufferPool)
NewBufferPool creates a new BufferPool bounded to the given size.
func (*BufferPool) Get ¶
func (bp *BufferPool) Get() (b *bytes.Buffer)
Get gets a Buffer from the BufferPool, or creates a new one if none are available in the pool.
func (*BufferPool) Put ¶
func (bp *BufferPool) Put(b *bytes.Buffer)
Put returns the given Buffer to the BufferPool.
type Grender ¶
type Grender struct {
Options Options
Templates templates
}
Grender provides functions for easily writing HTML templates & JSON out to a HTTP Response.
func (*Grender) HTML ¶
func (r *Grender) HTML(w http.ResponseWriter, statusCode int, templateName string, data interface{}) error
HTML executes the template and writes to the responsewriter
func (*Grender) JSON ¶
func (r *Grender) JSON(w http.ResponseWriter, statusCode int, data interface{}) error
JSON renders the data as a JSON HTTP response to the ResponseWriter
type Options ¶
type Options struct {
// With Debug set to true, templates will be recompiled before every render call.
Debug bool
// The glob string to your templates
TemplatesGlob string
// The Glob string for additional templates
PartialsGlob string
// The function map to pass to each HTML template
Funcs template.FuncMap
// Charset for responses
Charset string
}
Options holds the configuration Options for a Renderer
Click to show internal directories.
Click to hide internal directories.