mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
tpl: Add limit support to replaceRE
Go stdlib doesn't contain a limited replace in the regexp package, but we can accomplish the same thing with ReplaceAllStringFunc. Fixes #7586
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
047af7cfe5
commit
cdfd1c99ba
@@ -99,7 +99,16 @@ func init() {
|
||||
|
||||
ns.AddMethodMapping(ctx.ReplaceRE,
|
||||
[]string{"replaceRE"},
|
||||
[][2]string{},
|
||||
[][2]string{
|
||||
{
|
||||
`{{ replaceRE "a+b" "X" "aabbaabbab" }}`,
|
||||
`XbXbX`,
|
||||
},
|
||||
{
|
||||
`{{ replaceRE "a+b" "X" "aabbaabbab" 1 }}`,
|
||||
`Xbaabbab`,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
ns.AddMethodMapping(ctx.SliceString,
|
||||
|
Reference in New Issue
Block a user