Documentation
¶
Overview ¶
Package template facilitates processing of JSON strings using Go templates. Provides additional functions not available using basic Go templates, such as coloring, and table rendering.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolString ¶ added in v0.8.0
BoolString formats a *bool as a string. Returns "" for nil, "true"/"false" otherwise. Useful as a Go template helper via WithFuncs.
func FormatDuration ¶ added in v0.8.0
FormatDuration returns a human-readable duration string (e.g. "2m13s").
func HasItems ¶ added in v0.8.0
HasItems returns true if v is a non-nil, non-empty slice/array. Accepts a pointer to a slice or a slice directly.
func HasText ¶ added in v0.8.0
HasText returns true if v is a non-nil, non-whitespace string. For non-string pointer types it returns true if v is non-nil. Useful as a Go template helper via WithFuncs.
func StringOrEmpty ¶ added in v0.8.0
StringOrEmpty is a nil-safe string dereference. Accepts any value: returns "" for nil, typed nil pointers, *string, or string; returns the string value otherwise. Useful as a Go template helper via WithFuncs.
func UUIDString ¶ added in v0.8.0
UUIDString formats a *uuid.UUID as a string. Returns "" for nil, the UUID string otherwise. Useful as a Go template helper via WithFuncs.
Types ¶
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is the representation of a template.
func (*Template) Execute ¶
Execute applies the parsed template to the input and writes result to the writer the template was initialized with.
func (*Template) ExecuteData ¶
func (*Template) Flush ¶
Flush writes any remaining data to the writer. This is mostly useful when a templates uses the tablerow function but does not include the tablerender function at the end. If a template did not use the table functionality this is a noop.