Skip to content

Commit 4d3e492

Browse files
authored
Merge pull request #196 from iamazeem/cli-11572-expose-replace-sprig-function
Expose `replace` sprig function
2 parents e1048df + 663e33c commit 4d3e492

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/template/template.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func sprigFuncMap() template.FuncMap {
272272
"hasPrefix",
273273
"hasSuffix",
274274
"regexMatch",
275+
"replace",
275276
}
276277
txtFuncMap := sprig.TxtFuncMap()
277278
funcMap := template.FuncMap{}

pkg/template/template_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,14 @@ func TestExecute(t *testing.T) {
409409
},
410410
wantW: "true",
411411
},
412+
{
413+
name: "replace",
414+
args: args{
415+
json: strings.NewReader(`{"product":"GitHub CLI\n"}`),
416+
template: `{{ .product | replace "\n" "" }}`,
417+
},
418+
wantW: "GitHub CLI",
419+
},
412420
}
413421
for _, tt := range tests {
414422
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)