render

package
v0.19.1138 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsurePrefix

func EnsurePrefix(data map[string]interface{}) map[string]interface{}

func Exists

func Exists(path string, data map[string]interface{}) bool

func RenderMap

func RenderMap(obj any, data map[string]any) error

func RenderStruct

func RenderStruct(obj any, data map[string]any) error

want to write a type that can walk an object recursively and any field that has a struct

func RenderTextStringMap added in v0.19.1086

func RenderTextStringMap(m map[string]string, data map[string]interface{}) error

RenderTextStringMap renders every value of m in place using RenderTextV2.

func RenderTextV2 added in v0.19.1086

func RenderTextV2(inputVal string, data map[string]interface{}) (string, error)

RenderTextV2 does the same thing as RenderV2, but using "text/template" instead of "html/template", so special characters are not escaped. Use it for values that end up in infrastructure APIs rather than in a browser: an input value containing "&" or a quote renders as "&" / """ through RenderV2, which silently corrupts things like CloudFormation parameters.

func RenderV2

func RenderV2(inputVal string, data map[string]interface{}) (string, error)

func RenderVar

func RenderVar(v Var, data map[string]interface{}) (string, error)

func RenderWithWarnings

func RenderWithWarnings(inputVal string, data map[string]interface{}) (string, []error, error)

RenderWithWarnings walks through the template variable by variable and will return well formed errors for any partial that was "unrenderable".

func ValidateTextTemplate added in v0.19.1086

func ValidateTextTemplate(inputVal string) error

ValidateTextTemplate reports whether inputVal parses against the same function set RenderTextV2 executes with. Use it to reject a bad template early (e.g. at config sync) instead of failing later at render time.

Types

type RenderErr

type RenderErr struct {
	Name     string
	Template string
	Err      error
}

func (RenderErr) Error

func (r RenderErr) Error() string

func (RenderErr) Unwrap

func (r RenderErr) Unwrap() error

type Var

type Var struct {
	Template string
	Name     string
}

func Parse

func Parse(str string) []Var

Parse returns a list of all the template uses in a string, which allows for better rendering in the case of errors. NOTE: this can _not_ be used to reconstruct the original template using strings.Join() as any actual content will be removed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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