Documentation ¶
Overview ¶
Package template provides support for evaluating text templates in Aptomi, with support for caching compiled templates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe cache of compiled text templates
func (*Cache) Evaluate ¶
func (cache *Cache) Evaluate(templateStr string, params *Parameters) (string, error)
Evaluate evaluates text template given a set of parameters. If an compiled text template already exists in cache, it will be used. Otherwise it will get compiled and added to the cache before evaluating the text template. This method is thread-safe and can be called concurrently from multiple goroutines.
type Parameters ¶
type Parameters struct {
// contains filtered or unexported fields
}
Parameters is a set of named parameters for the text template
func NewParams ¶
func NewParams(params interface{}) *Parameters
NewParams creates a new instance of Parameters
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template struct contains text template string as well as its compiled version
func NewTemplate ¶
NewTemplate compiles a text template and returns the result in Template struct Parameter templateStr must follow syntax defined by text/template