Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultFuncs ¶ added in v0.0.11
DefaultFuncs returns Notifykit's default template helper functions.
The returned map is a fresh copy and can be modified by callers.
Types ¶
type MissingKey ¶
type MissingKey string
MissingKey controls how templates behave when a map key is missing.
const ( // MissingKeyDefault keeps the default text/template behavior and renders "<no value>". MissingKeyDefault MissingKey = "default" // MissingKeyZero renders the zero value for the missing key's element type. MissingKeyZero MissingKey = "zero" // MissingKeyError returns an execution error when a key is missing. MissingKeyError MissingKey = "error" )
type Option ¶
type Option func(*options)
Option customizes template parsing.
func WithDefaultFuncs ¶ added in v0.0.11
func WithDefaultFuncs() Option
WithDefaultFuncs enables Notifykit's default template helper functions.
func WithMissingKey ¶
func WithMissingKey(policy MissingKey) Option
WithMissingKey configures the text/template missingkey option.
type StringTemplate ¶
type StringTemplate struct {
// contains filtered or unexported fields
}
StringTemplate wraps a parsed template that renders strings.
func LoadString ¶
func LoadString(path string, opts ...Option) (*StringTemplate, error)
LoadString reads a file and parses it into a StringTemplate.
func LoadStringFromFS ¶
LoadStringFromFS reads a file from an fs.FS into a StringTemplate.
func ParseStringTemplate ¶
func ParseStringTemplate(name, input string, opts ...Option) (*StringTemplate, error)
ParseStringTemplate parses a string-rendering template from a string.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template wraps a parsed template that renders bytes.
func LoadFromFS ¶
LoadFromFS reads and parses a template from an fs.FS.
func LoadSource ¶
LoadSource reads and parses a template from a file path or builtin reference.
func ParseTemplate ¶
ParseTemplate parses a byte-rendering template from a string.