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.
See renderer.ExtraFunctions for our custom functions.
Detailed documentation on the syntax and available functions can be found here:
Index ¶
- Constants
- func Gzip(input interface{}) (string, error)
- func ToYaml(marshallable interface{}) (string, error)
- func Ungzip(input interface{}) (string, error)
- type Renderer
- func (r *Renderer) ExtraFunctions() template.FuncMap
- func (r *Renderer) ReadFile(file string) (string, error)
- func (r *Renderer) Render(templateName, rawTemplate string) (string, error)
- func (r *Renderer) RenderFile(inputPath, outputPath string) error
- func (r *Renderer) RenderWith(templateName, rawTemplate string, extraFunctions template.FuncMap) (string, error)
- func (r *Renderer) SimpleRender(rawTemplate string) (string, 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" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer structure holds configuration and options
func New ¶
func New(configuration configuration.Configuration, opts ...string) *Renderer
New creates a new renderer with the specified configuration and zero or more options
func (*Renderer) ExtraFunctions ¶ added in v0.0.4
ExtraFunctions provides additional template functions to the standard (text/template) ones, it adds sprig functions and custom functions:
- render - calls the render from inside of the template, making the renderer recursive
- readFile - reads a file from a given path, relative paths are translated to absolute paths, based on root function
- root - the root path for rendering, used relative to absolute path translation in any file based operations
- toYaml - provides a configuration data structure fragment as a YAML format
- gzip - use gzip compression inside the templates, for best results use with b64enc
- ungzip - use gzip extraction inside the templates, for best results use with b64dec
func (*Renderer) ReadFile ¶
ReadFile is a template function that allows for an in-template file opening
func (*Renderer) Render ¶
Render is the main rendering function, see also SimpleRender, RenderWith, Configuration and ExtraFunctions
func (*Renderer) RenderFile ¶
RenderFile is used to render files by path, see also Render
Directories
¶
Path | Synopsis |
---|---|
Package configuration defines data structure (configuration) for the data-driven renderer Configuration is a tree structure and can be created from a YAML files or 'key=value' pairs.
|
Package configuration defines data structure (configuration) for the data-driven renderer Configuration is a tree structure and can be created from a YAML files or 'key=value' pairs. |