diff --git a/pkg/template/template.go b/pkg/template/template.go index 6c9b1b5..49aa001 100644 --- a/pkg/template/template.go +++ b/pkg/template/template.go @@ -272,6 +272,7 @@ func sprigFuncMap() template.FuncMap { "hasPrefix", "hasSuffix", "regexMatch", + "replace", } txtFuncMap := sprig.TxtFuncMap() funcMap := template.FuncMap{} diff --git a/pkg/template/template_test.go b/pkg/template/template_test.go index c25a4f4..6c4e0e6 100644 --- a/pkg/template/template_test.go +++ b/pkg/template/template_test.go @@ -409,6 +409,14 @@ func TestExecute(t *testing.T) { }, wantW: "true", }, + { + name: "replace", + args: args{ + json: strings.NewReader(`{"product":"GitHub CLI\n"}`), + template: `{{ .product | replace "\n" "" }}`, + }, + wantW: "GitHub CLI", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {