templates

package
v0.0.20-beta Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(field string, values any) (string, error)

func ApplyAndSet

func ApplyAndSet(field *string, values any) (err error)

Types

type Option added in v0.0.13

type Option func(*Processor)

Option is a function that modifies a Processor.

func WithMissingKeyDefault added in v0.0.13

func WithMissingKeyDefault() Option

WithMissingKeyDefault sets missing keys to display "<no value>".

func WithMissingKeyError added in v0.0.13

func WithMissingKeyError() Option

WithMissingKeyError makes missing keys return an error.

func WithMissingKeyZero added in v0.0.13

func WithMissingKeyZero() Option

WithMissingKeyZero sets missing keys to use the zero value.

func WithSlimSprig added in v0.0.13

func WithSlimSprig() Option

WithSlimSprig adds slim-sprig functions.

type Processor added in v0.0.13

type Processor struct {
	// contains filtered or unexported fields
}

Processor handles template processing with configurable options.

func New added in v0.0.13

func New(opts ...Option) *Processor

New creates a processor with the given options.

func (*Processor) AddFuncs added in v0.0.13

func (p *Processor) AddFuncs(funcs ...template.FuncMap)

AddFuncs adds or updates multiple functions.

func (*Processor) AddValue added in v0.0.13

func (p *Processor) AddValue(key string, value any)

AddValue adds or updates a single value.

func (*Processor) AddValues added in v0.0.13

func (p *Processor) AddValues(values ...map[string]any)

AddValues adds or updates multiple values.

func (*Processor) Apply added in v0.0.13

func (p *Processor) Apply(templateStr string) (string, error)

Apply processes a template string with the accumulated values.

func (*Processor) ApplyAndSet added in v0.0.13

func (p *Processor) ApplyAndSet(field *string) error

func (*Processor) Reset added in v0.0.13

func (p *Processor) Reset()

Reset clears all accumulated values.

func (*Processor) Values added in v0.0.13

func (p *Processor) Values() map[string]any

func (*Processor) WithOptions added in v0.0.13

func (p *Processor) WithOptions(opts ...Option) *Processor

func (*Processor) WithValues added in v0.0.13

func (p *Processor) WithValues(values ...map[string]any) *Processor

Jump to

Keyboard shortcuts

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