mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-20 03:43:14 +00:00
Make all the params to Replace an interface{}
This commit is contained in:
parent
e08cabadb6
commit
4f4015d751
1 changed files with 10 additions and 2 deletions
|
@ -890,12 +890,20 @@ func Trim(a interface{}, b string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace all occurences of b with c in a
|
// Replace all occurences of b with c in a
|
||||||
func Replace(a interface{}, b string, c string) (string, error) {
|
func Replace(a, b, c interface{}) (string, error) {
|
||||||
aStr, err := cast.ToStringE(a)
|
aStr, err := cast.ToStringE(a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return strings.Replace(aStr, b, c, -1), nil
|
bStr, err := cast.ToStringE(b)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
cStr, err := cast.ToStringE(c)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return strings.Replace(aStr, bStr, cStr, -1), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SafeHtml(text string) template.HTML {
|
func SafeHtml(text string) template.HTML {
|
||||||
|
|
Loading…
Add table
Reference in a new issue