Documentation
¶
Overview ¶
Package templates provides tree-based template loading and rendering using HTML templates from the Go standard library.
Use Templates to obtain an acceptable.Processor loaded with the specified template files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultPage = "_index.html"
DefaultPage is the template name when a blank string is supplied. Alter this during startup if required.
var Fs = afero.NewOsFs()
Fs is used to obtain file information and content. It can be stubbed for testing.
var GZIPLevel = offer.MidCompression
GZIPLevel sets the compression strength when gzip is applied to a response entity. This is in the range 1 to 9 inclusive (see gzip.NewWriterLevel). High values should be avoided because the cpu cost is high but the benefit may not be sufficient.
This controls template responses only.
var ReloadOnTheFly = false
ReloadOnTheFly enables a development mode that reloads template files whenever they change, without restarting the server. This reduces performance and should be off (false) for production.
Functions ¶
func ApplicationXhtmlOffer ¶
ApplicationXhtmlOffer is an Offer for application/xhtml+xml content using the Template() processor.
func Templates ¶
Templates finds all the templates in the directory dir and its subdirectories that have names ending with the given suffix (usually ".html").
Optionally, the suffix can be a pipe-separated list, e.g. ".html|.js".
The function map (see template.FuncMap) can be nil if not required.
A processor is returned that handles requests using the templates available.
The response will use gzip compression (see GZIPLevel) when the client requests it.
Types ¶
This section is empty.