tpl

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delims

type Delims struct {
	Left  string
	Right string
}

Delims delims for template

type FuncMap

type FuncMap map[string]any

FuncMap is the type of the map defining the mapping from names to functions. Each function must have either a single return value, or two return values of which the second has type error. In that case, if the second (error) argument evaluates to non-nil during execution, execution terminates and Execute returns that error. FuncMap has the same base type as FuncMap in "text/template", copied here so clients need not import "text/template".

func Functions

func Functions() FuncMap

Functions default utility functions for template

func (FuncMap) Copy

func (fm FuncMap) Copy(fms ...FuncMap)

Copy copy functions from other function maps `fms`

type HTMLTemplates

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

HTMLTemplates html template engine

func NewHTMLTemplates

func NewHTMLTemplates(extensions ...string) *HTMLTemplates

NewHTMLTemplates new template engine

func (*HTMLTemplates) Delims

func (ht *HTMLTemplates) Delims(left, right string)

Delims sets template left and right delims and returns a Engine instance.

func (*HTMLTemplates) Extensions

func (ht *HTMLTemplates) Extensions(extensions ...string)

Extensions sets template entensions.

func (*HTMLTemplates) Funcs

func (ht *HTMLTemplates) Funcs(funcMap FuncMap)

Funcs sets the FuncMap used for template.FuncMap.

func (*HTMLTemplates) Load

func (ht *HTMLTemplates) Load(root string) (err error)

Load glob and parse template files under the root path

func (*HTMLTemplates) LoadFS

func (ht *HTMLTemplates) LoadFS(fsys fs.FS, root string) (err error)

LoadFS glob and parse template files from FS

func (*HTMLTemplates) Render

func (ht *HTMLTemplates) Render(w io.Writer, name string, data any) error

Render render template with io.Writer

type Templates

type Templates interface {
	// Extensions sets template entensions.
	Extensions(extensions ...string)

	// Delims sets template left and right delims and returns a Engine instance.
	Delims(left, right string)

	// Funcs sets the FuncMap used for template.FuncMap.
	Funcs(funcMap FuncMap)

	// Load glob and parse template files under the root path
	Load(root string) error

	// LoadFS glob and parse template files from FS
	LoadFS(fsys fs.FS, root string) error

	// Render render template with io.Writer
	Render(w io.Writer, name string, data any) error
}

Templates templates interface

type TextTemplates

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

TextTemplates text template engine

func NewTextTemplates

func NewTextTemplates(extensions ...string) *TextTemplates

NewTextTemplates new templates instance

func (*TextTemplates) Delims

func (tt *TextTemplates) Delims(left, right string)

Delims sets template left and right delims and returns a Engine instance.

func (*TextTemplates) Extensions

func (tt *TextTemplates) Extensions(extensions ...string)

Extensions sets template entensions.

func (*TextTemplates) Funcs

func (tt *TextTemplates) Funcs(funcMap FuncMap)

Funcs sets the FuncMap used for template.FuncMap.

func (*TextTemplates) Load

func (tt *TextTemplates) Load(root string) (err error)

Load glob and parse template files under the root path

func (*TextTemplates) LoadFS

func (tt *TextTemplates) LoadFS(fsys fs.FS, root string) (err error)

LoadFS glob and parse template files from FS

func (*TextTemplates) Render

func (tt *TextTemplates) Render(w io.Writer, name string, data any) error

Render render template with io.Writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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