You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +02:00
feat: Add trimprefix function to template package (#2116)
This allows templates to trim prefixes. Particularly useful for removing the v prefix from versions
This commit is contained in:
@@ -166,11 +166,12 @@ func (t *Template) Apply(s string) (string, error) {
|
||||
"time": func(s string) string {
|
||||
return time.Now().UTC().Format(s)
|
||||
},
|
||||
"tolower": strings.ToLower,
|
||||
"toupper": strings.ToUpper,
|
||||
"trim": strings.TrimSpace,
|
||||
"dir": filepath.Dir,
|
||||
"abs": filepath.Abs,
|
||||
"tolower": strings.ToLower,
|
||||
"toupper": strings.ToUpper,
|
||||
"trim": strings.TrimSpace,
|
||||
"trimprefix": strings.TrimPrefix,
|
||||
"dir": filepath.Dir,
|
||||
"abs": filepath.Abs,
|
||||
}).
|
||||
Parse(s)
|
||||
if err != nil {
|
||||
|
||||
@@ -188,6 +188,11 @@ func TestFuncMap(t *testing.T) {
|
||||
Name: "tolower",
|
||||
Expected: "test",
|
||||
},
|
||||
{
|
||||
Template: `{{ trimprefix "v1.2.4" "v" }}`,
|
||||
Name: "trimprefix",
|
||||
Expected: "1.2.4",
|
||||
},
|
||||
{
|
||||
Template: `{{ toupper "test" }}`,
|
||||
Name: "toupper",
|
||||
|
||||
Reference in New Issue
Block a user