templates

package
v0.0.0-...-c971602 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2014 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const SERVER_ERROR_TEMPLATE = `` /* 430-byte string literal not displayed */

Variables

View Source
var (
	TemplatePath = "templates"
)

Functions

func AddHelper

func AddHelper(name string, f interface{})

AddHelper registers functions with TemplateBroker that will be available in templates during rendering.

func TemplateBroker

func TemplateBroker(r *gadget.Request, status int, body interface{}, data *gadget.RouteData) (int, string)

TemplateBroker attempts to render interface{} value body as the context of a html/template.Template. It requires adherence to a few simple conventions for locating templates: 1) all templates are inside a "templates" directory in the root directory of the Gadget application; 2) a "templates/base.html" file exists and can be parsed as a Go template; 3) templates will be loaded from a directory matching the lower-cased plural name of the controller and the lower-cased name of the action, plus the extension ".html". For example, the Show method of a FavoriteController would look for a template "templates/favorites/show.html."

All error codes can also be served via their own templates. Non-200 statuses will result in TemplateBroker looking for a "templates/403.html", "templates/502.html", etc.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL