Documentation
¶
Overview ¶
Package templateloader provides different strategies for loading html templates in a web application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerFunc ¶
HandlerFunc is an extension to http.HandlerFunc that takes an html template as first argument. Used in conjunction with the Loader interface.
type Loader ¶
type Loader interface { // Load returns an http.HandlerFunc that passes a loaded html template to the supplied HandlerFunc. // name should correspond to the main template to load for this handler. Load(name string, h HandlerFunc, templateFiles ...string) (http.HandlerFunc, error) }
The Loader describes a common interface for loading html templates that can be used with a HandlerFunc.
func NewOnRequestLoader ¶
func NewOnRequestLoader() Loader
NewOnRequestLoader creates a Loader that loads and parses the template on each request. Useful for development, as changes to template files are reflected on the next request. If the template cannot be parsed, the errors will show when the resulting handler is invoked.
func NewPreloader ¶
func NewPreloader() Loader
NewPreloader creates a Loader that loads and parses the template when Load is called. If the template cannot be parsed, an error is returned as the result of Load.