Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomFunctions ¶
type CustomFunctions interface {
// CustomTemplateFunctions should return the mapping from custom function names to implementations.
CustomTemplateFunctions() template.FuncMap
}
Customfunctions is the interface for registering custom template functions.
type TemplateContext ¶
type TemplateContext struct {
Root http.FileSystem
Req *http.Request
Args []interface{} // defined by arguments to funcInclude
RespHeader WrappedHeader
CustomFuncs []template.FuncMap // functions added by plugins
// contains filtered or unexported fields
}
TemplateContext is the TemplateContext with which HTTP templates are executed.
func (TemplateContext) Cookie ¶
func (c TemplateContext) Cookie(name string) string
Cookie gets the value of a cookie with name name.
func (TemplateContext) Host ¶
func (c TemplateContext) Host() (string, error)
Host returns the hostname portion of the Host header from the HTTP request.
func (*TemplateContext) NewTemplate ¶
func (c *TemplateContext) NewTemplate(tplName string) *template.Template
NewTemplate returns a new template intended to be evaluated with this context, as it is initialized with configuration from this context.
func (TemplateContext) OriginalReq ¶
func (c TemplateContext) OriginalReq() http.Request
OriginalReq returns the original, unmodified, un-rewritten request as it originally came in over the wire.
func (TemplateContext) RemoteIP ¶
func (c TemplateContext) RemoteIP() string
RemoteIP gets the IP address of the client making the request.
type Templates ¶
type Templates struct {
// The root path from which to load files. Required if template functions
// accessing the file system are used (such as include). Default is
// `{http.vars.root}` if set, or current working directory otherwise.
FileRoot string `json:"file_root,omitempty"`
// The MIME types for which to render templates. It is important to use
// this if the route matchers do not exclude images or other binary files.
// Default is text/plain, text/markdown, and text/html.
MIMETypes []string `json:"mime_types,omitempty"`
// The template action delimiters. If set, must be precisely two elements:
// the opening and closing delimiters. Default: `["{{", "}}"]`
Delimiters []string `json:"delimiters,omitempty"`
// contains filtered or unexported fields
}
func (Templates) CaddyModule ¶
func (Templates) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
type WrappedHeader ¶
WrappedHeader wraps niladic functions so that they can be used in templates. (Template functions must return a value.)
func (WrappedHeader) Add ¶
func (h WrappedHeader) Add(field, val string) string
Add adds a header field value, appending val to existing values for that field. It returns an empty string.
func (WrappedHeader) Del ¶
func (h WrappedHeader) Del(field string) string
Del deletes a header field. It returns an empty string.
func (WrappedHeader) Set ¶
func (h WrappedHeader) Set(field, val string) string
Set sets a header field value, overwriting any other values for that field. It returns an empty string.