renderer: github.com/thedevsaddam/renderer Index | Files

package renderer

import "github.com/thedevsaddam/renderer"

Package renderer documentaton contains the API for this package please follow the link below

Index

Package Files

renderer.go

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"
)

type M Uses

type M map[string]interface{}

M describes handy type that represents data to send as response

type Options Uses

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 Uses

type Render struct {
    // contains filtered or unexported fields
}

Render describes a renderer type

func New Uses

func New(opts ...Options) *Render

New return a new instance of a pointer to Render

func (*Render) Binary Uses

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) Charset Uses

func (r *Render) Charset(c string) *Render

Charset change the Charset for response on the fly

func (*Render) Delims Uses

func (r *Render) Delims(left, right string) *Render

Delims set template delimiter on the fly

func (*Render) DisableCharset Uses

func (r *Render) DisableCharset(b bool) *Render

DisableCharset change the DisableCharset for JSON on the fly

func (*Render) EscapeHTML Uses

func (r *Render) EscapeHTML(b bool) *Render

EscapeHTML change the EscapeHTML for JSON on the fly

func (*Render) File Uses

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 Uses

func (r *Render) FileDownload(w http.ResponseWriter, status int, fpath, name string) error

FileDownload serve file as response with content-disposition value attachment

func (*Render) FileView Uses

func (r *Render) FileView(w http.ResponseWriter, status int, fpath, name string) error

FileView serve file as response with content-disposition value inline

func (*Render) FuncMap Uses

func (r *Render) FuncMap(fmap template.FuncMap) *Render

FuncMap set template FuncMap on the fly

func (*Render) HTML Uses

func (r *Render) HTML(w http.ResponseWriter, status int, name string, v interface{}) error

HTML render html from template.Glob patterns and execute template by name. See README.md for detail example.

func (*Render) JSON Uses

func (r *Render) JSON(w http.ResponseWriter, status int, v interface{}) error

JSON serve data as JSON as response

func (*Render) JSONIndent Uses

func (r *Render) JSONIndent(b bool) *Render

JSONIndent change the JSONIndent for JSON on the fly

func (*Render) JSONP Uses

func (r *Render) JSONP(w http.ResponseWriter, status int, callback string, v interface{}) error

JSONP serve data as JSONP response

func (*Render) NoContent Uses

func (r *Render) NoContent(w http.ResponseWriter) error

NoContent serve success but no content response

func (*Render) Render Uses

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 Uses

func (r *Render) String(w http.ResponseWriter, status int, v interface{}) error

String serve string content as text/plain response

func (*Render) Template Uses

func (r *Render) Template(w http.ResponseWriter, 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 Uses

func (r *Render) View(w http.ResponseWriter, status int, name string, v interface{}) error

View build html from template directory and serve html content as response. See README.md for detail example.

func (*Render) XML Uses

func (r *Render) XML(w http.ResponseWriter, status int, v interface{}) error

XML serve data as XML response

func (*Render) XMLIndent Uses

func (r *Render) XMLIndent(b bool) *Render

XMLIndent change the XMLIndent for XML on the fly

func (*Render) YAML Uses

func (r *Render) YAML(w http.ResponseWriter, status int, v interface{}) error

YAML serve data as YAML response

Package renderer imports 12 packages (graph). Updated 2017-11-18. Refresh now. Tools for package owners.