chore: deprecate TxtFuncMap

This commit is contained in:
andig 2024-06-26 10:20:20 +02:00
parent a833be77b7
commit c04f52f851
7 changed files with 8 additions and 8 deletions

View file

@ -116,7 +116,7 @@ var configTmpl string
// RenderConfiguration creates a yaml configuration
func (c *Configure) RenderConfiguration() ([]byte, error) {
tmpl, err := template.New("yaml").Funcs(sprout.TxtFuncMap()).Parse(configTmpl)
tmpl, err := template.New("yaml").Funcs(sprout.FuncMap()).Parse(configTmpl)
if err != nil {
panic(err)
}

View file

@ -70,7 +70,7 @@ func runDump(cmd *cobra.Command, args []string) {
tmpl := template.Must(
template.New("dump").
Funcs(sprout.TxtFuncMap()).
Funcs(sprout.FuncMap()).
Parse(dumpTmpl))
out := new(bytes.Buffer)

View file

@ -42,7 +42,7 @@ func generateEEBUSCert() {
log.FATAL.Fatal("could not process generated certificate", err)
}
t := template.Must(template.New("out").Funcs(sprout.TxtFuncMap()).Parse(tmpl))
t := template.Must(template.New("out").Funcs(sprout.FuncMap()).Parse(tmpl))
if err := t.Execute(os.Stdout, map[string]interface{}{
"public": pubKey,
"private": privKey,

View file

@ -38,10 +38,10 @@ type Hub struct {
func NewHub(cc map[string]EventTemplateConfig, vv Vehicles, cache *util.Cache) (*Hub, error) {
// instantiate all event templates
for k, v := range cc {
if _, err := template.New("out").Funcs(sprout.TxtFuncMap()).Parse(v.Title); err != nil {
if _, err := template.New("out").Funcs(sprout.FuncMap()).Parse(v.Title); err != nil {
return nil, fmt.Errorf("invalid event title: %s (%w)", k, err)
}
if _, err := template.New("out").Funcs(sprout.TxtFuncMap()).Parse(v.Msg); err != nil {
if _, err := template.New("out").Funcs(sprout.FuncMap()).Parse(v.Msg); err != nil {
return nil, fmt.Errorf("invalid event message: %s (%w)", k, err)
}
}

View file

@ -44,7 +44,7 @@ func (t *Template) RenderDocumentation(product Product, lang string) ([]byte, er
var modbusRender string
if modbusChoices := t.ModbusChoices(); len(modbusChoices) > 0 {
if i, _ := t.ParamByName(ParamModbus); i > -1 {
modbusTmpl, err := template.New("yaml").Funcs(sprout.TxtFuncMap()).Parse(documentationModbusTmpl)
modbusTmpl, err := template.New("yaml").Funcs(sprout.FuncMap()).Parse(documentationModbusTmpl)
if err != nil {
panic(err)
}

View file

@ -208,7 +208,7 @@ var proxyTmpl string
// RenderProxyWithValues renders the proxy template
func (t *Template) RenderProxyWithValues(values map[string]interface{}, lang string) ([]byte, error) {
tmpl, err := template.New("yaml").Funcs(sprout.TxtFuncMap()).Parse(proxyTmpl)
tmpl, err := template.New("yaml").Funcs(sprout.FuncMap()).Parse(proxyTmpl)
if err != nil {
panic(err)
}

View file

@ -59,5 +59,5 @@ func FuncMap(tmpl *template.Template) *template.Template {
"urlEncode": url.QueryEscape,
}
return tmpl.Funcs(sprout.TxtFuncMap()).Funcs(funcMap)
return tmpl.Funcs(sprout.FuncMap()).Funcs(funcMap)
}