renderer

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 3

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

This section is empty.

Variables

This section is empty.

Functions

func WithDelim added in v0.0.2

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

WithDelim mutates Renderer configuration with new left and right delimiters

func WithFunctions added in v0.0.2

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

WithFunctions mutates Renderer configuration with new template functions

func WithOptions added in v0.0.2

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

WithOptions mutates Renderer configuration with new template functions

func WithParameters added in v0.0.2

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

WithParameters mutates Renderer configuration with new template parameters

Types

type Renderer

type Renderer interface {
	Configuration() config.Config
	Reconfigure(configurators ...func(*config.Config))

	Render(rawTemplate string) (string, error)
	NamedRender(templateName, rawTemplate string) (string, error)
	Validate() error
	Parse(templateName, rawTemplate string, extraFunctions template.FuncMap) (*template.Template, error)
	Execute(t *template.Template) (string, error)
}

Renderer allows for parameterised text template rendering

func New

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

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

func NewWithConfig added in v0.0.3

func NewWithConfig(conf config.Config) Renderer

NewWithConfig creates a new custom renderer with the specified configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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