Documentation ¶
Index ¶
- type Templates
- func (t *Templates) Delims(left, right string) *Templates
- func (t *Templates) Execute(wr io.Writer, name string, data interface{}) error
- func (t *Templates) Funcs(funcMap template.FuncMap) *Templates
- func (t *Templates) Lookup(name string) *template.Template
- func (t *Templates) ParseDir(dir string, exts ...string) (*Templates, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Templates ¶
type Templates struct {
// contains filtered or unexported fields
}
Templates is a specialized set of templates from "text/template"
func Must ¶
Must is a helper that wraps a call to a function returning (*Templates, error) and panics if the error is non-nil. It is intended for use in variable initializations such as
var t = tpl.Must(tpl.New().ParseDir("html", []string{".html"}))
func New ¶
func New() *Templates
New allocates a new set of templates that can be inited via ParseDir function
func (*Templates) Delims ¶
Delims sets the action delimiters to the specified strings, to be used in subsequent calls to Parse, ParseFiles, or ParseGlob. Nested template definitions will inherit the settings. An empty delimiter stands for the corresponding default: {{ or }}. The return value is the template, so calls can be chained.
func (*Templates) Execute ¶
Execute applies a parsed template to the specified data object, writing the output to wr. If an error occurs executing the template or writing its output, execution stops, but partial results may already have been written to the output writer. A template may be executed safely in parallel, although if parallel executions share a Writer the output may be interleaved.
func (*Templates) Funcs ¶
Funcs adds the elements of the argument map to the template's function map. It must be called before the template is parsed. It panics if a value in the map is not a function with appropriate return type. However, it is legal to overwrite elements of the map. The return value is the template, so calls can be chained.