Documentation
¶
Index ¶
Constants ¶
View Source
const ( ContentType = "Content-Type" ContentLength = "Content-Length" ContentBinary = "application/octet-stream" ContentJSON = "application/json" ContentHTML = "text/html" ContentXHTML = "application/xhtml+xml" ContentXML = "text/xml" )
Variables ¶
This section is empty.
Functions ¶
func LoadWithFuncMap ¶
LoadWithFuncMap prepares and parses all templates from the passed basePath and injects a custom template.FuncMap into each template
Types ¶
type Options ¶
type Options struct {
// Directory to load templates. Default is "templates"
Directory string
// Extensions to parse template files from. Defaults to [".tmpl"]
Extensions []string
// Funcs is a slice of FuncMaps to apply to the template upon compilation. This is useful for helper functions. Defaults to [].
Funcs template.FuncMap
// Appends the given charset to the Content-Type header. Default is "UTF-8".
Charset string
// Outputs human readable JSON
IndentJSON bool
// Outputs human readable XML
IndentXML bool
// Prefixes the JSON output with the given bytes.
PrefixJSON []byte
// Prefixes the XML output with the given bytes.
PrefixXML []byte
// Allows changing of output to XHTML instead of HTML. Default is "text/html"
HTMLContentType string
}
Options is a struct for specifying configuration options for the render.Renderer middleware
type Render ¶
type Render interface {
// JSON writes the given status and JSON serialized version of the given value to the http.ResponseWriter.
JSON(status int, v interface{})
// HTML renders a html template specified by the name and writes the result and given status to the http.ResponseWriter.
HTML(status int, name string, v interface{})
// XML writes the given status and XML serialized version of the given value to the http.ResponseWriter.
XML(status int, v interface{})
// Data writes the raw byte array to the http.ResponseWriter.
Data(status int, v []byte)
// Error is a convenience function that writes an http status to the http.ResponseWriter.
Error(status int)
// Status is an alias for Error (writes an http status to the http.ResponseWriter)
Status(status int)
// Redirect is a convienience function that sends an HTTP redirect. If status is omitted, uses 302 (Found)
Redirect(location string, status ...int)
// Template returns the internal *template.Template used to render the HTML
Template(name string) *template.Template
// Header exposes the header struct from http.ResponseWriter.
Header() http.Header
}
Click to show internal directories.
Click to hide internal directories.