renderer

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

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

This section is empty.

Variables

This section is empty.

Functions

func ExtraFunctions added in v0.0.6

func ExtraFunctions() template.FuncMap

ExtraFunctions provides additional template functions to the standard (text/template) ones:

  • 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 Gzip added in v0.0.4

func Gzip(input interface{}) (string, error)

Gzip compresses the input using gzip algorithm

func MergeFunctions added in v0.0.6

func MergeFunctions(dst *template.FuncMap, src template.FuncMap) error

MergeFunctions merges two template.FuncMap instances, overrides if necessary

func ToYaml added in v0.0.4

func ToYaml(marshallable interface{}) (string, error)

ToYaml is a template function, it turns a marshallable structure into a YAML fragment

func Ungzip added in v0.0.4

func Ungzip(input interface{}) (string, error)

Ungzip un-compresses the input using gzip algorithm

func WithCryptFunctions added in v0.0.6

func WithCryptFunctions() func(*config.Config)

WithCryptFunctions mutates Renderer configuration by merging the Crypt template functions

func WithDelim added in v0.0.6

func WithDelim(left, right string) func(*config.Config)

WithDelim mutates Renderer configuration by replacing the left and right delimiters

func WithExtraFunctions added in v0.0.6

func WithExtraFunctions() func(*config.Config)

WithExtraFunctions mutates Renderer configuration by merging the custom template functions

func WithFunctions added in v0.0.6

func WithFunctions(extraFunctions template.FuncMap) func(*config.Config)

WithFunctions mutates Renderer configuration by replacing the template functions

func WithMoreFunctions added in v0.0.6

func WithMoreFunctions(moreFunctions template.FuncMap) func(*config.Config)

WithMoreFunctions mutates Renderer configuration by merging the given template functions,

func WithMoreParameters added in v0.0.8

func WithMoreParameters(extraParams ...map[string]interface{}) func(*config.Config)

WithMoreParameters mutates Renderer configuration by merging the given template parameters

func WithOptions added in v0.0.6

func WithOptions(options ...string) func(*config.Config)

WithOptions mutates Renderer configuration by replacing the template functions

func WithParameters added in v0.0.6

func WithParameters(parameters map[string]interface{}) func(*config.Config)

WithParameters mutates Renderer configuration by replacing all template parameters

func WithSprigFunctions added in v0.0.6

func WithSprigFunctions() func(*config.Config)

WithSprigFunctions mutates Renderer configuration by merging the Sprig template functions

Types

type Renderer

type Renderer interface {
	base.Renderer
	Clone(configurators ...func(*config.Config)) Renderer
	FileRender(inputPath, outputPath string) error
	DirRender(inputDir, outputDir string) error
	NestedRender(args ...interface{}) (string, error)
	ReadFile(file string) (string, error)
}

Renderer allows for parameterised text template rendering

func New

func New(configurators ...func(*config.Config)) Renderer

New creates a new renderer with the specified parameters and zero or more options

Directories

Path Synopsis
Package parameters defines data structure for the data-driven renderer Parameters is a tree structure and can be created from a YAML files or 'key=value' pairs.
Package parameters defines data structure for the data-driven renderer Parameters is a tree structure and can be created from a YAML files or 'key=value' pairs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL