Documentation ¶
Overview ¶
Package tmpl wraps a lot of html/template for easier use with common layout setup and sub-templates
Index ¶
- type FuncMap
- type TRoot
- func (t *TRoot) Build(path string) (*Template, error)
- func (t *TRoot) Clone() *TRoot
- func (t *TRoot) Funcs(fnList FuncMap) *TRoot
- func (t *TRoot) MustBuild(path string) *Template
- func (t *TRoot) MustReadPartials(files ...string)
- func (t *TRoot) Name() string
- func (t *TRoot) ReadPartials(files ...string) error
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TRoot ¶
type TRoot struct { Path string // contains filtered or unexported fields }
TRoot wraps template.Template for use to spawn "real" templates. The TRoot is never meant to be directly rendered itself, but a top-level object for collecting the template path on disk, a layout template and shared templates (e.g., sidebar), and template functions for reuse in renderable templates
func Root ¶
Root creates a new TRoot for use in spawning templates. The name should match the main layout's name (as defined in the layout template) so execution of templates doesn't require a template.Lookup call, which can be somewhat error prone.
func (*TRoot) Build ¶
Build clones the root (for layout, funcs, etc) and parses the given file in the clone. The returned template is the clone, and is safe to alter without worrying about breaking the root.
func (*TRoot) Clone ¶
Clone creates a copy of the TRoot for ease of creating sub-layouts. Since TRoots cannot be executed externally, we don't have the possibility of returning an error.
func (*TRoot) Funcs ¶
Funcs allows adding template function maps to TRoots; this should be done before creating any templates, or else previously created templates won't get the newest function maps
func (*TRoot) MustReadPartials ¶
MustReadPartials calls ReadPartials and panics on any error
func (*TRoot) ReadPartials ¶
ReadPartials parses the given files into the TRoot instance for gathering things like the top-level layout, navigation elements, etc. The list of files is relative to the TRoot's Path. Returns on the first error encountered, if any.