template

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParseTemplate = errors.New("template: parse template files")
)

Functions

This section is empty.

Types

type FS

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

An FS provides access to a file system that produces a safe HTML document templates.

func NewFS

func NewFS(fsys fs.FS) *FS

NewFS allocates a new file system for templates

func (*FS) Funcs

func (fsys *FS) Funcs(funcs ...template.FuncMap) *FS

Funcs adds the elements of the argument map to the template's function map.

func (*FS) MustParse

func (fsys *FS) MustParse(filenames ...string) Template

MustParse will panic if unable to parse files

func (*FS) Parse

func (fsys *FS) Parse(filenames ...string) (Template, error)

Parse parses the named files and associates the resulting templates with t

type Template

type Template interface {
	// Execute applies a parsed template to the specified data object, writing the output to wr
	Execute(wr io.Writer, data any) error
	// ExecuteTemplate applies the template associated with t that has the given
	// name to the specified data object and writes the output to wr.
	ExecuteTemplate(wr io.Writer, name string, data any) error
}

Jump to

Keyboard shortcuts

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