templating

package
v0.0.0-...-54d739a Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine is a template engine based on template.Template with some additional functions. Don't create objects of this type directly, use the NewTemplate function instead.

func (*Engine) Execute

func (e *Engine) Execute(writer io.Writer, name string, data any) error

Execute executes the template with the given name and passing the given input data. It writes the result to the given writer.

func (*Engine) Names

func (e *Engine) Names() []string

Names returns the names of the templates.

type EngineBuilder

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

EngineBuilder contains the data and logic needed to create templates. Don't create objects of this type directly, use the NewTemplate function instead.

func NewEngine

func NewEngine() *EngineBuilder

NewEngine creates a builder that can the be used to create a template engine.

func (*EngineBuilder) Build

func (b *EngineBuilder) Build() (result *Engine, err error)

Build uses the configuration stored in the builder to create a new engine.

func (*EngineBuilder) SetDir

func (b *EngineBuilder) SetDir(value string) *EngineBuilder

SetDir instructs the engine to load load the templates only from the given directory of the filesystem. This is optional and the default is to load all the templates.

func (*EngineBuilder) SetFS

func (b *EngineBuilder) SetFS(value fs.FS) *EngineBuilder

SetFS sets the filesystem that will be used to read the templates. This is mandatory.

func (*EngineBuilder) SetLogger

func (b *EngineBuilder) SetLogger(value logr.Logger) *EngineBuilder

SetLogger sets the logger that the engine will use to write messages to the log. This is mandatory.

Jump to

Keyboard shortcuts

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