mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
feat(macros): add sprig functions to macros (#733)
This commit is contained in:
parent
d100703784
commit
e29cd9d80a
2 changed files with 22 additions and 2 deletions
|
@ -7,6 +7,8 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/autobrr/autobrr/pkg/errors"
|
||||
|
||||
"github.com/Masterminds/sprig/v3"
|
||||
)
|
||||
|
||||
type Macro struct {
|
||||
|
@ -70,7 +72,7 @@ func (m Macro) Parse(text string) (string, error) {
|
|||
}
|
||||
|
||||
// setup template
|
||||
tmpl, err := template.New("macro").Parse(text)
|
||||
tmpl, err := template.New("macro").Funcs(sprig.TxtFuncMap()).Parse(text)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "could parse macro template")
|
||||
}
|
||||
|
@ -91,7 +93,7 @@ func (m Macro) MustParse(text string) string {
|
|||
}
|
||||
|
||||
// setup template
|
||||
tmpl, err := template.New("macro").Parse(text)
|
||||
tmpl, err := template.New("macro").Funcs(sprig.TxtFuncMap()).Parse(text)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue