tmpl

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TemplateContext

type TemplateContext struct {
	Data      interface{}
	Functions map[string]TemplateFunc
	// contains filtered or unexported fields
}

TemplateContext contains data and functions to be passed to templates

func NewTemplateContext

func NewTemplateContext(opts ...TemplateContextOptions) *TemplateContext

NewTemplateContext creates a new TemplateContext with default functions

func (*TemplateContext) InstantiateTemplate

func (ctx *TemplateContext) InstantiateTemplate(reader io.Reader, writer io.Writer) error

InstantiateTemplate reads a template from the reader, executes it with the context, and writes the result to the writer

type TemplateContextOptions

type TemplateContextOptions func(*TemplateContext)

func WithBaseDir

func WithBaseDir(basedir string) TemplateContextOptions

func WithData

func WithData(data interface{}) TemplateContextOptions

func WithFunction

func WithFunction(name string, fn TemplateFunc) TemplateContextOptions

type TemplateFunc

type TemplateFunc any

TemplateFunc represents a function that can be used in templates

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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