Documentation ¶
Index ¶
- type Config
- type Loader
- type Set
- func (s *Set) Add(files ...string) *Set
- func (s *Set) AddFunc(name string, fn interface{}) *Set
- func (s *Set) AddFuncs(funcMap map[string]interface{}) *Set
- func (s *Set) AddSet(set *Set) *Set
- func (s *Set) AddSets(sets ...*Set) *Set
- func (s *Set) Funcs() map[string]interface{}
- func (s *Set) Set(name, file string) *Set
- func (s *Set) Sources() []Source
- func (s *Set) View() (*View, error)
- func (s *Set) ViewMust() *View
- type Source
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Directories define the file paths to search for templates, // ordered by descending priority. Directories []string // AutoReload is whether the templates should be reloaded on rendering. // This is useful in development, but should be disabled in production. AutoReload bool // DelimLeft is the delimiter that marks the start of a template action. DelimLeft string // DelimRight is the delimiter that marks the stop of a template action. DelimRight string }
Config controls the behaviour of the template loading and rendering.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader collects the available template sources. It creates new sets and triggers the template parsing.
func NewLoader ¶
NewLoader creates a new loader. It scans the provided source directories and collects all available template sources.
func (*Loader) AddFile ¶
AddFile adds a file-based template source. It overwrites any existing source with the same name.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a collection of template sources. It allows to create a View from its sources.
func (*Set) Add ¶
Add appends a template source, identified by its file path, to the set. A copy of the set is returned.
func (*Set) AddFunc ¶
AddFunc appends a named function to the set's function map. It is legal to overwrite elements of the map. A copy of the set is returned.
func (*Set) AddFuncs ¶
AddFuncs appends the functions of the passed-in function map to the set's function map. It is legal to overwrite elements of the map. A copy of the set is returned.
func (*Set) AddSet ¶
AddSet appends the template sources of another set to this one. A copy of the set is returned.
func (*Set) AddSets ¶
AddSets appends the template sources of other sets to this one. It returns a copy of the Set.
func (*Set) Set ¶
Set appends a template source, identified by its file path and name, to the set. A copy of the set is returned.
type Source ¶
Source is a template data source. It contains an optional path to the source's file source.