diff --git a/templatefuncs.go b/templatefuncs.go index f3c487b..fe770fb 100644 --- a/templatefuncs.go +++ b/templatefuncs.go @@ -43,8 +43,10 @@ func NewFuncMap() template.FuncMap { "prefixLines": prefixLinesTemplateFunc, "quote": eachString(strconv.Quote), "regexpReplaceAll": regexpReplaceAllTemplateFunc, - "replaceAll": func(old, new, s string) string { - return strings.ReplaceAll(s, old, new) + "replaceAll": func(old, new_ string, v any) any { + return eachString(func(s string) any { + return strings.ReplaceAll(s, old, new_) + })(v) }, "stat": eachString(statTemplateFunc), "toJSON": toJSONTemplateFunc, diff --git a/templatefuncs_test.go b/templatefuncs_test.go index fd7f102..5a13fa6 100644 --- a/templatefuncs_test.go +++ b/templatefuncs_test.go @@ -122,6 +122,10 @@ func TestFuncMap(t *testing.T) { template: `{{ "abcba" | replaceAll "b" "d" }}`, expected: `adcda`, }, + { + template: `{{ list "abc" "cba" | replaceAll "b" "d" }}`, + expected: "[adc cda]", + }, { template: `{{ quote "a" }}`, expected: `"a"`,