template

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextProcessorFunc

type ContextProcessorFunc = func(echoCtx echo.Context, pongoCtx pongo2.Context)

ContextProcessorFunc signature.

type EmbedReadFileFunc

type EmbedReadFileFunc = func(name string) ([]byte, error)

type Template

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

Template implements custom pongo2 rendering engine for echo.

func NewTemplate

func NewTemplate() *Template

NewTemplate creates a new Template struct.

func (*Template) Abs

func (this *Template) Abs(base, name string) string

Abs returns absolute path to file requested. Search path is configured in AddDirectory method. And default directory is "./templates".

func (*Template) AddDirectory

func (this *Template) AddDirectory(dir string)

AddDirectory adds a directory to the list of directories searched for templates. Default directory is "./templates".

func (*Template) AddFuncs

func (this *Template) AddFuncs(fns map[string]any)

添加方法

func (*Template) Get

func (this *Template) Get(path string) (io.Reader, error)

Get reads the path's content from your local filesystem.

func (*Template) RegisterFilter

func (this *Template) RegisterFilter(name string, fn pongo2.FilterFunction)

RegisterFilter registers a custom filter. It calls pongo2.RegisterFilter method.

func (*Template) RegisterTag

func (this *Template) RegisterTag(name string, parserFunc pongo2.TagParser)

RegisterTag registers a custom tag. It calls pongo2.RegisterTag method.

func (*Template) Render

func (this *Template) Render(w io.Writer, name string, data interface{}, ctx echo.Context) error

Render renders the view. Many other times, this is called in your echo handler functions.

func (*Template) SetDebug

func (this *Template) SetDebug(v bool)

SetDebug sets debug mode to the template set. See pongo2.TemplateSet.Debug for more information.

func (*Template) SetEmbedReadFileFunc

func (this *Template) SetEmbedReadFileFunc(embedReadFileFunc EmbedReadFileFunc)

设置读取函数

func (*Template) SetUseEmbed

func (this *Template) SetUseEmbed(useEmbed bool)

是否使用打包文件

func (*Template) UseContextProcessor

func (this *Template) UseContextProcessor(processor ContextProcessorFunc)

UseContextProcessor adds context processor to the pipeline.

Jump to

Keyboard shortcuts

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