Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Templater ¶
Templater returns a middleware handler that injects template.Templater and template.Data into the request context, which are used for rendering templates to the ResponseWriter.
When running with flamego.EnvTypeDev, if either Directory or AppendDirectories is specified, templates will be recompiled upon every request.
Types ¶
type Data ¶
type Data map[string]interface{}
Data is used as the root object for rendering a template.
type Delims ¶
type Delims struct { // Left is the left delimiter. Default is "{{". Left string // Right is the right delimiter. Default is "}}". Right string }
Delims is a pair of Left and Right delimiters for rendering HTML templates.
type File ¶
type File interface { // Name returns the name of the file, stripping its extension. It should return // "home" not "home.tmpl". Name() string // Data returns the file content. Data() ([]byte, error) // Ext returns the file extension, carrying the dot ("."). It should return // ".tmpl" not "tmpl". Ext() string }
File is a template file that contains name, data and its extension.
type FileSystem ¶
type FileSystem interface { // Files returns the the list of template files. Files() []File }
FileSystem is a template file system consists a list of template files.
type Options ¶
type Options struct { // FileSystem is the interface for supporting any implementation of the // FileSystem. FileSystem FileSystem // Directory is the primary directory to load templates. This value is ignored // when FileSystem is set. Default is "templates". Directory string // AppendDirectories is a list of additional directories to load templates for // overwriting templates that are loaded from FileSystem or Directory. AppendDirectories []string // Extensions is a list of extensions to be used for template files. Default is // `[".tmpl", ".html"]`. Extensions []string // FuncMaps is a list of `template.FuncMap` to be applied for rendering // templates. FuncMaps []gotemplate.FuncMap // Delims is the pair of left and right delimiters for rendering templates. Delims Delims // ContentType specifies the value of "Content-Type". Default is "text/html". ContentType string }
Options contains options for the template.Templater middleware.