Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is responsible for evaluating templates and producing outputs.
func NewEngine ¶
NewEngine creates a new templating engine that will read template includes from the given file system.
func (*Engine) DryRun ¶
DryRun parses and executes the template at the given path, but wraps all registered functions with no-ops that simply record their arguments.
func (*Engine) Execute ¶
Execute parses the template at the given path, executes it, and writes it to the given writer.
As the template is being executed, functions registered with [Register] may call their BomWriter to add material to the bill. These materials are collated and returned once the template has been executed.
Because of the way materials are gathered, the Execute method is not thread safe.
func (*Engine) Register ¶
func (e *Engine) Register(source FunctionSource)
Register registers functions for use in templates. The FunctionSource is given a BomWriter that it should call whenever functions are called that depend on some material.
If Register is called with sources that return functions with conflicting names, later instances of the functions replace earlier ones.