This repository was archived by the owner on Jun 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -307,6 +307,20 @@ Render:
307307100
308308` ` `
309309
310+ # ### replace
311+
312+ Replaces all occurrences of the search string with the replacement string.
313+
314+ Example :
315+ ` ` `
316+ [[ replace "Batman and Robin" "Robin" "Catwoman" ]]
317+ ` ` `
318+
319+ Render :
320+ ` ` `
321+ Batman and Catwoman
322+ ` ` `
323+
310324# ### timeNow
311325
312326Returns the current ISO_8601 standard timestamp as a string in the timezone of the machine the rendering was triggered on.
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ func funcMap(consulClient *consul.Client) template.FuncMap {
3131 "parseInt" : parseInt ,
3232 "parseJSON" : parseJSON ,
3333 "parseUint" : parseUint ,
34+ "replace" : replace ,
3435 "timeNow" : timeNowFunc ,
3536 "timeNowUTC" : timeNowUTCFunc ,
3637 "timeNowTimezone" : timeNowTimezoneFunc (),
@@ -202,6 +203,10 @@ func parseUint(s string) (uint64, error) {
202203 return result , nil
203204}
204205
206+ func replace (input , from , to string ) string {
207+ return strings .Replace (input , from , to , - 1 )
208+ }
209+
205210func timeNowFunc () string {
206211 return time .Now ().Format ("2006-01-02T15:04:05Z07:00" )
207212}
You can’t perform that action at this time.
0 commit comments