Documentation
¶
Index ¶
- Variables
- func Any(value any, data any) (any, error)
- func DefaultFuncMap() template.FuncMap
- func File(path string, data any) (string, error)
- func Map(values map[string]any, data any) (map[string]any, error)
- func Slice(values []any, data any) ([]any, error)
- func String(s string, data any) (string, error)
- type Template
Constants ¶
This section is empty.
Variables ¶
var ( // The function map to use when rendering templates. FuncMap = DefaultFuncMap() )
Functions ¶
func Any ¶ added in v0.11.0
Any attempts to render strings in the given value with data. The input value is assumed to come from an untyped map[string]any (typically from decoding unknown JSON or YAML).
Delegates internally to Map, Slice, and String (see the documentation for those functions for more info). Other types are returned unchanged.
func DefaultFuncMap ¶
DefaultFuncMap returns a map of functions for the template engine. It includes everything from sprig.FuncMap, plus a number of functions from flect.
Types ¶
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is a lightweight wrapper for template strings.
Since it implements the encoding.TextMarshaler and encoding.TextUnmarshaler interfaces, it can be used with JSON or YAML fields containing template strings.
func Compile ¶
Compile parses a template string and returns, if successful, a new Template that can be rendered.
func MustCompile ¶
MustCompile behaves like Compile, but panics on error.
func (*Template) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Template) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.