template: Add reReplaceAll function (#639)
This allows for using regexp replacement in templates.
This commit is contained in:
parent
412d33336d
commit
00e3b98614
|
@ -17,6 +17,7 @@ import (
|
|||
"bytes"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -130,6 +131,10 @@ var DefaultFuncs = FuncMap{
|
|||
"safeHtml": func(text string) tmplhtml.HTML {
|
||||
return tmplhtml.HTML(text)
|
||||
},
|
||||
"reReplaceAll": func(pattern, repl, text string) string {
|
||||
re := regexp.MustCompile(pattern)
|
||||
return re.ReplaceAllString(text, repl)
|
||||
},
|
||||
}
|
||||
|
||||
// Pair is a key/value string pair.
|
||||
|
|
Loading…
Reference in New Issue