Documentation ¶
Overview ¶
Package renderer documentaton contains the API for this package please follow the link below
Index ¶
- Constants
- func AddTokenCSRF(w http.ResponseWriter, r *http.Request, inf interface{}) interface{}
- type BayurDT
- type BayurData
- type Options
- type Render
- func (r *Render) Binary(w http.ResponseWriter, status int, reader io.Reader, filename string, ...) error
- func (r *Render) Charset(c string) *Render
- func (r *Render) Delims(left, right string) *Render
- func (r *Render) DisableCharset(b bool) *Render
- func (r *Render) EscapeHTML(b bool) *Render
- func (r *Render) File(w http.ResponseWriter, status int, reader io.Reader, filename string, ...) error
- func (r *Render) FileDownload(w http.ResponseWriter, status int, fpath, name string) error
- func (r *Render) FileView(w http.ResponseWriter, status int, fpath, name string) error
- func (r *Render) FuncMap(fmap template.FuncMap) *Render
- func (r *Render) HTML(w http.ResponseWriter, status int, name string, v interface{}) error
- func (r *Render) HTMLString(w http.ResponseWriter, status int, html string) error
- func (r *Render) JSON(w http.ResponseWriter, status int, v interface{}) error
- func (r *Render) JSONIndent(b bool) *Render
- func (r *Render) JSONP(w http.ResponseWriter, status int, callback string, v interface{}) error
- func (r *Render) NoContent(w http.ResponseWriter) error
- func (r *Render) Render(w http.ResponseWriter, status int, v interface{}) error
- func (r *Render) String(w http.ResponseWriter, status int, v interface{}) error
- func (r *Render) Template(w http.ResponseWriter, rq *http.Request, status int, tpls []string, ...) error
- func (r *Render) View(w http.ResponseWriter, status int, name string, v interface{}) error
- func (r *Render) XML(w http.ResponseWriter, status int, v interface{}) error
- func (r *Render) XMLIndent(b bool) *Render
- func (r *Render) YAML(w http.ResponseWriter, status int, v interface{}) error
Constants ¶
const ( // ContentType represents content type ContentType string = "Content-Type" // ContentJSON represents content type application/json ContentJSON string = "application/json" // ContentJSONP represents content type application/javascript ContentJSONP string = "application/javascript" // ContentXML represents content type application/xml ContentXML string = "application/xml" // ContentYAML represents content type application/x-yaml ContentYAML string = "application/x-yaml" // ContentHTML represents content type text/html ContentHTML string = "text/html" // ContentText represents content type text/plain ContentText string = "text/plain" // ContentBinary represents content type application/octet-stream ContentBinary string = "application/octet-stream" // ContentDisposition describes contentDisposition ContentDisposition string = "Content-Disposition" )
Variables ¶
This section is empty.
Functions ¶
func AddTokenCSRF ¶
func AddTokenCSRF(w http.ResponseWriter, r *http.Request, inf interface{}) interface{}
Types ¶
type Options ¶
type Options struct { // Charset represents the Response charset; default: utf-8 Charset string // ContentJSON represents the Content-Type for JSON ContentJSON string // ContentJSONP represents the Content-Type for JSONP ContentJSONP string // ContentXML represents the Content-Type for XML ContentXML string // ContentYAML represents the Content-Type for YAML ContentYAML string // ContentHTML represents the Content-Type for HTML ContentHTML string // ContentText represents the Content-Type for Text ContentText string // ContentBinary represents the Content-Type for octet-stream ContentBinary string // UnEscapeHTML set UnEscapeHTML for JSON; default false UnEscapeHTML bool // DisableCharset set DisableCharset in Response Content-Type DisableCharset bool // Debug set the debug mode. if debug is true then every time "VIEW" call parse the templates Debug bool // JSONIndent set JSON Indent in response; default false JSONIndent bool // XMLIndent set XML Indent in response; default false XMLIndent bool // JSONPrefix set Prefix in JSON response JSONPrefix string // XMLPrefix set Prefix in XML response XMLPrefix string // TemplateDir set the Template directory TemplateDir string // TemplateExtension set the Template extension TemplateExtension string // LeftDelim set template left delimiter default is {{ LeftDelim string // RightDelim set template right delimiter default is }} RightDelim string // LayoutExtension set the Layout extension LayoutExtension string // FuncMap contain function map for template FuncMap []template.FuncMap // ParseGlobPattern contain parse glob pattern ParseGlobPattern string }
Options describes an option type
type Render ¶
type Render struct {
// contains filtered or unexported fields
}
Render describes a renderer type
func (*Render) Binary ¶
func (r *Render) Binary(w http.ResponseWriter, status int, reader io.Reader, filename string, inline bool) error
Binary serve file as application/octet-stream response; you may add ContentDisposition by your own.
func (*Render) DisableCharset ¶
DisableCharset change the DisableCharset for JSON on the fly
func (*Render) EscapeHTML ¶
EscapeHTML change the EscapeHTML for JSON on the fly
func (*Render) File ¶
func (r *Render) File(w http.ResponseWriter, status int, reader io.Reader, filename string, inline bool) error
File serve file as response from io.Reader
func (*Render) FileDownload ¶
FileDownload serve file as response with content-disposition value attachment
func (*Render) HTML ¶
HTML render html from template.Glob patterns and execute template by name. See README.md for detail example.
func (*Render) HTMLString ¶
HTMLString render string as html. Note: You must provide trusted html when using this method
func (*Render) JSON ¶
func (r *Render) JSON(w http.ResponseWriter, status int, v interface{}) error
JSON serve data as JSON as response
func (*Render) JSONIndent ¶
JSONIndent change the JSONIndent for JSON on the fly
func (*Render) NoContent ¶
func (r *Render) NoContent(w http.ResponseWriter) error
NoContent serve success but no content response
func (*Render) Render ¶
func (r *Render) Render(w http.ResponseWriter, status int, v interface{}) error
Render serve raw response where you have to build the headers, body
func (*Render) String ¶
func (r *Render) String(w http.ResponseWriter, status int, v interface{}) error
String serve string content as text/plain response
func (*Render) Template ¶
func (r *Render) Template(w http.ResponseWriter, rq *http.Request, status int, tpls []string, v interface{}) error
Template build html from template and serve html content as response. See README.md for detail example.
func (*Render) View ¶
View build html from template directory and serve html content as response. See README.md for detail example.
func (*Render) XML ¶
func (r *Render) XML(w http.ResponseWriter, status int, v interface{}) error
XML serve data as XML response