jade: github.com/go-macaron/jade Index | Files

package jade

import "github.com/go-macaron/jade"

Index

Package Files

render.go

Constants

const (
    ContentType   = "Content-Type"
    ContentLength = "Content-Length"
    ContentJSON   = "application/json"
    ContentHTML   = "text/html"
)

func Renderer Uses

func Renderer(options ...Options) macaron.Handler

Renderer is a Middleware that maps a render.Render service into the Macaron handler chain. An single variadic render.Options struct can be optionally provided to configure HTML rendering. The default directory for templates is "templates" and the default file extension is ".tmpl".

If MARTINI_ENV is set to "" or "development" then templates will be recompiled on every request. For more performance, set the MARTINI_ENV environment variable to "production"

type Delims Uses

type Delims struct {
    // Left delimiter, defaults to {{
    Left string
    // Right delimiter, defaults to }}
    Right string
}

Delims represents a set of Left and Right delimiters for HTML template rendering

type HTMLOptions Uses

type HTMLOptions struct {
    // Layout template name. Overrides Options.Layout.
    Layout string
}

HTMLOptions is a struct for overriding some rendering Options for specific HTML call

type Options Uses

type Options struct {
    // Directory to load templates. Default is "templates"
    Directory string
    // Layout template name. Will not render a layout if "". Defaults to "".
    //Layout string // Not working in jade
    // 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
    // Delims sets the action delimiters to the specified strings in the Delims struct.
    Delims Delims
    // Appends the given charset to the Content-Type header. Default is "UTF-8".
    Charset string
    // Outputs human readable JSON
    IndentJSON bool
}

Options is a struct for specifying configuration options for the render.Renderer middleware

type Render Uses

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{}, htmlOpt ...HTMLOptions)
    // Error is a convenience function that writes an http status to the http.ResponseWriter.
    Error(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() *template.Template
}

Render is a service that can be injected into a Macaron handler. Render provides functions for easily writing JSON and HTML templates out to a http Response.

Package jade imports 10 packages (graph) and is imported by 3 packages. Updated 2016-10-26. Refresh now. Tools for package owners.