Skip to content

Commit

Permalink
chore: deprecate TxtFuncMap
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jun 26, 2024
1 parent a833be7 commit c04f52f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/eebus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions push/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion util/templates/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion util/templates/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion util/templates/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit c04f52f

Please sign in to comment.