Documentation ¶
Index ¶
Constants ¶
const SERVER_ERROR_TEMPLATE = `` /* 430-byte string literal not displayed */
Variables ¶
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.