template

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMetaData

func AddMetaData(key MetaKey, val interface{}) error

func GetMetaData

func GetMetaData(key MetaKey) interface{}

func RenderText

func RenderText(tmplText string, data interface{}) ([]byte, error)

func RenderText2File

func RenderText2File(tmplText, destFile string, data interface{}) error

Types

type Config

type Config struct {
	//渲染模板资源根路径 配置的其它文件都相对该路径
	BasePath string
	//模板来源
	TplFile, TplDir, TplText string
	//渲染模板输出 如果都没配置就输出到控制台
	DestDir, DestFile string
	DestStdout        bool
	//变量开始和结束标志
	LeftDelim, RightDelim string
	//自定义函数
	Funcs FuncMap
	//渲染模板的数据
	Data interface{}
}

func (*Config) Render

func (c *Config) Render(data ...interface{}) ([]byte, error)

func (*Config) Write

func (c *Config) Write(data ...interface{}) error

支持渲染结果输出到控制台、文件、文件目录(只有模板文件为目录时有效)

type FuncMap

type FuncMap template.FuncMap

type MetaKey

type MetaKey interface{}

Jump to

Keyboard shortcuts

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