package
1.3.48
Repository: https://github.com/sandwich-go/boost.git
Documentation: pkg.go.dev

# README

xtemplate

tempalte 辅助函数

  • 模板中支持 github.com/Masterminds/sprig.FuncMap 返回的函数
  • 支持生成指定文件
  • 支持 go 文件格式化

例子

s := `a {{ .val1 }} {{ .val2 }}`
s1, err := Execute(s, map[string]interface{}{"val1": "b", "val2": 2})
xpanic.WhenError(err)
fmt.Println(string(s1))

Output:

a b 2

# Functions

Execute 根据指定的 template 以及 args 生成对应文本内容.
InstallOptionsWatchDog the installed func will called when NewOptions called.
NewOptions new Options.
go:generate optiongen --option_with_struct_name=true --option_return_previous=false.
WithOptionFileName 文件名称,若不为空,则会生成对应的文件,若文件为 .go 文件,则会格式化.
WithOptionFilers 在生成指定文件或返回模板填充后数据前,指定过滤器,可以对数据进行二次加工.
WithOptionName 指定模板的名称.

# Structs

Options should use NewOptions to initialize it.

# Interfaces

OptionsInterface visitor + ApplyOption interface for Options.
OptionsVisitor visitor interface for Options.

# Type aliases

Filter 过滤器 在生成指定文件或返回模板填充后数据前,可以指定过滤器对数据进行二次加工.
Option option func.