engine

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ECache

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

cache is the cache used by default in a new Set.

func (*ECache) Del

func (c *ECache) Del(templatePath string)

func (*ECache) Get

func (c *ECache) Get(templatePath string) *jet.Template

func (*ECache) Put

func (c *ECache) Put(templatePath string, t *jet.Template)

type OSFileSystemLoader

type OSFileSystemLoader struct {
	Views  *jet.Set
	ECache *ECache
	// contains filtered or unexported fields
}

自定义文件系统loader,满足和Mem相同的操作行为 OSFileSystemLoader implements Loader interface using OS file system (os.File).

func NewOSFileSystemLoader

func NewOSFileSystemLoader(dirPath string, views *jet.Set, ecache *ECache) *OSFileSystemLoader

NewOSFileSystemLoader returns an initialized OSFileSystemLoader.

func (*OSFileSystemLoader) Delete

func (l *OSFileSystemLoader) Delete(templatePath string)

func (*OSFileSystemLoader) Exists

func (l *OSFileSystemLoader) Exists(templatePath string) bool

Exists returns true if a file is found under the template path after converting it to a file path using the OS's path seperator and joining it with the loader's directory path.

func (*OSFileSystemLoader) Open

func (l *OSFileSystemLoader) Open(templatePath string) (io.ReadCloser, error)

Open returns the result of `os.Open()` on the file located using the same logic as Exists().

func (*OSFileSystemLoader) Set

func (l *OSFileSystemLoader) Set(templatePath string, contents string)

type TemplateEngine

type TemplateEngine struct {
	Views  *jet.Set
	IsFs   *bool
	Loader *TemplateLoader
}

模板引擎配置

func CreateWithFile

func CreateWithFile(dir string) *TemplateEngine

根据本地文件创建

func CreateWithMem

func CreateWithMem() *TemplateEngine

根据内存创建

type TemplateLoader

type TemplateLoader interface {
	jet.Loader
	Set(templatePath, contents string)
	Delete(templatePath string)
}

模板文件加载器

Jump to

Keyboard shortcuts

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