Documentation
¶
Index ¶
- type AnyTemplate
- func (t *AnyTemplate) Execute(data map[string]any) (interface{}, error)
- func (t *AnyTemplate) ExecuteAsString(data map[string]any) string
- func (t *AnyTemplate) ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
- func (t *AnyTemplate) HasVar() bool
- func (t *AnyTemplate) IsNotVar() bool
- func (t *AnyTemplate) Parse() error
- type ExprTemplate
- func (t *ExprTemplate) Execute(data map[string]any) (interface{}, error)
- func (t *ExprTemplate) ExecuteAsString(data map[string]any) string
- func (t *ExprTemplate) ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
- func (t *ExprTemplate) HasVar() bool
- func (t *ExprTemplate) IsNotVar() bool
- func (t *ExprTemplate) Parse() error
- type MixedTemplate
- func (t *MixedTemplate) Execute(data map[string]any) (interface{}, error)
- func (t *MixedTemplate) ExecuteAsString(data map[string]any) string
- func (t *MixedTemplate) ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
- func (t *MixedTemplate) ExecuteFnAsString(loadDataFunc func() map[string]any) string
- func (t *MixedTemplate) HasVar() bool
- func (t *MixedTemplate) IsNotVar() bool
- func (t *MixedTemplate) Parse() error
- type NotTemplate
- func (t *NotTemplate) Execute(data map[string]any) (interface{}, error)
- func (t *NotTemplate) ExecuteAsString(data map[string]any) string
- func (t *NotTemplate) ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
- func (t *NotTemplate) HasVar() bool
- func (t *NotTemplate) IsNotVar() bool
- func (t *NotTemplate) Parse() error
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyTemplate ¶
type AnyTemplate struct {
Tmpl any
}
func (*AnyTemplate) Execute ¶
func (t *AnyTemplate) Execute(data map[string]any) (interface{}, error)
func (*AnyTemplate) ExecuteAsString ¶
func (t *AnyTemplate) ExecuteAsString(data map[string]any) string
ExecuteAsString 执行模板并返回字符串结果
func (*AnyTemplate) ExecuteFn ¶
func (t *AnyTemplate) ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
ExecuteFn 执行模板函数
func (*AnyTemplate) HasVar ¶
func (t *AnyTemplate) HasVar() bool
func (*AnyTemplate) IsNotVar ¶
func (t *AnyTemplate) IsNotVar() bool
func (*AnyTemplate) Parse ¶
func (t *AnyTemplate) Parse() error
type ExprTemplate ¶
ExprTemplate 模板变量支持 这种方式 ${xx},使用expr表达式计算
func NewExprTemplate ¶
func NewExprTemplate(tmpl string) (*ExprTemplate, error)
func (*ExprTemplate) Execute ¶
func (t *ExprTemplate) Execute(data map[string]any) (interface{}, error)
func (*ExprTemplate) ExecuteAsString ¶
func (t *ExprTemplate) ExecuteAsString(data map[string]any) string
ExecuteAsString 执行模板并返回字符串结果
func (*ExprTemplate) ExecuteFn ¶
func (t *ExprTemplate) ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
func (*ExprTemplate) HasVar ¶
func (t *ExprTemplate) HasVar() bool
func (*ExprTemplate) IsNotVar ¶
func (t *ExprTemplate) IsNotVar() bool
func (*ExprTemplate) Parse ¶
func (t *ExprTemplate) Parse() error
type MixedTemplate ¶
type MixedTemplate struct {
Tmpl string
// contains filtered or unexported fields
}
MixedTemplate 支持混合字符串和变量的模板,格式如 aa/${xxx}
func NewMixedTemplate ¶
func NewMixedTemplate(tmpl string) (*MixedTemplate, error)
func (*MixedTemplate) Execute ¶
func (t *MixedTemplate) Execute(data map[string]any) (interface{}, error)
func (*MixedTemplate) ExecuteAsString ¶
func (t *MixedTemplate) ExecuteAsString(data map[string]any) string
func (*MixedTemplate) ExecuteFn ¶
func (t *MixedTemplate) ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
func (*MixedTemplate) ExecuteFnAsString ¶
func (t *MixedTemplate) ExecuteFnAsString(loadDataFunc func() map[string]any) string
func (*MixedTemplate) HasVar ¶
func (t *MixedTemplate) HasVar() bool
func (*MixedTemplate) IsNotVar ¶
func (t *MixedTemplate) IsNotVar() bool
func (*MixedTemplate) Parse ¶
func (t *MixedTemplate) Parse() error
type NotTemplate ¶
type NotTemplate struct {
Tmpl string
}
NotTemplate 原样输出
func (*NotTemplate) Execute ¶
func (t *NotTemplate) Execute(data map[string]any) (interface{}, error)
func (*NotTemplate) ExecuteAsString ¶
func (t *NotTemplate) ExecuteAsString(data map[string]any) string
ExecuteAsString 执行模板并返回字符串结果
func (*NotTemplate) ExecuteFn ¶
func (t *NotTemplate) ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
ExecuteFn 执行模板函数
func (*NotTemplate) HasVar ¶
func (t *NotTemplate) HasVar() bool
func (*NotTemplate) IsNotVar ¶
func (t *NotTemplate) IsNotVar() bool
func (*NotTemplate) Parse ¶
func (t *NotTemplate) Parse() error
type Template ¶
type Template interface {
Parse() error
Execute(data map[string]any) (interface{}, error)
ExecuteFn(loadDataFunc func() map[string]any) (interface{}, error)
ExecuteAsString(data map[string]any) string
// Deprecated: Use HasVar instead.
// IsNotVar 是否是模板变量
IsNotVar() bool
// HasVar 是否有变量
HasVar() bool
}
Click to show internal directories.
Click to hide internal directories.