Documentation
¶
Overview ¶
Package renderer implements data-driven templates for generating textual output
The renderer extends the standard golang text/template and sprig functions.
Templates are executed by applying them to a data structure (configuration). Values in the template refer to elements of the data structure (typically a field of a struct or a key in a map).
Actions can be combined using UNIX-like pipelines.
The input text for a template is UTF-8-encoded text in any format.
Detailed documentation on the syntax and available functions can be found here:
Index ¶
- Constants
- type Renderer
- func (r *Renderer) Delim(left, right string) *Renderer
- func (r *Renderer) Execute(t *template.Template) (string, error)
- func (r *Renderer) Functions(extraFunctions template.FuncMap) *Renderer
- func (r *Renderer) NamedRender(templateName, rawTemplate string) (string, error)
- func (r *Renderer) Options(options ...string) *Renderer
- func (r *Renderer) Parameters(parameters map[string]interface{}) *Renderer
- func (r *Renderer) Parse(templateName, rawTemplate string, extraFunctions template.FuncMap) (*template.Template, error)
- func (r *Renderer) Render(rawTemplate string) (string, error)
- func (r *Renderer) Validate() error
Constants ¶
const ( // MissingKeyInvalidOption is the renderer option to continue execution on missing key and print "<no value>" MissingKeyInvalidOption = "missingkey=invalid" // MissingKeyErrorOption is the renderer option to stops execution immediately with an error on missing key MissingKeyErrorOption = "missingkey=error" // LeftDelim is the default left template delimiter LeftDelim = "{{" // RightDelim is the default right template delimiter RightDelim = "}}" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer structure holds parameters and options
func New ¶
func New() *Renderer
New creates a new renderer with the specified parameters and zero or more options
func (*Renderer) NamedRender ¶
NamedRender is the main rendering function, see also Render, Parameters and ExtraFunctions
func (*Renderer) Parameters ¶
Parameters mutates Renderer with new template parameters
func (*Renderer) Parse ¶
func (r *Renderer) Parse(templateName, rawTemplate string, extraFunctions template.FuncMap) (*template.Template, error)
Parse is a basic template parsing function