Documentation ¶
Overview ¶
Pongo implements a Django-syntax-like templating engine.
See the tests for examples.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Filters = map[string]FilterFunc{ "safe": filterSafe, "unsafe": nil, "lower": filterLower, "upper": filterUpper, "capitalize": filterCapitalize, "default": filterDefault, "trim": filterTrim, "length": filterLength, "join": filterJoin, "striptags": filterStriptags, "time_format": filterTimeFormat, "floatformat": filterFloatFormat, }
var Tags = map[string]*TagHandler{ "if": &TagHandler{Execute: tagIf, Ignore: tagIfIgnore}, "else": nil, "endif": nil, "for": &TagHandler{Execute: tagFor, Ignore: tagForIgnore}, "endfor": nil, "block": &TagHandler{Execute: tagBlock}, "endblock": nil, "extends": &TagHandler{}, "include": &TagHandler{}, "trim": &TagHandler{Execute: tagTrim, Ignore: tagTrimIgnore}, "endtrim": nil, "remove": &TagHandler{Execute: tagRemove, Ignore: tagRemoveIgnore}, "endremove": nil, }
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context map[string]interface{}
A Context is used to pass data to the template. You can pass whatever you want in interface{}.
type FilterChainContext ¶
type FilterChainContext struct { // Store what you want along the filter chain. Every filter has access to this store. Store map[string]interface{} // contains filtered or unexported fields }
func (*FilterChainContext) HasVisited ¶
func (ctx *FilterChainContext) HasVisited(names ...string) bool
type FilterFunc ¶
type FilterFunc func(interface{}, []interface{}, *FilterChainContext) (interface{}, error)
type TagHandler ¶
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
func FromFile ¶
Reads a template from file. If there's no templateLocator provided, one will be created to search for files in the same directory the template file is located. file_path can either be an absolute filepath or a relative one.
func FromString ¶
Creates a new template instance from string.
func Must ¶
The Must function is a little helper to create a template instance from string/file. It checks whether FromString/FromFile returns an error; if so, it panics. If not, it returns the template instance. Is's primarily used like this:
var tplExample = template.Must(template.FromFile("example.html", nil))