Make all the params to Replace an interface{} - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 4f4015d751f7422e448c86ee7c57e11c546901a9
DIR parent e08cabadb6f0d61b818dfe4be404decb6c6e8ca2
HTML Author: bep <bjorn.erik.pedersen@gmail.com>
Date: Sun, 18 Jan 2015 15:16:48 +0100
Make all the params to Replace an interface{}
Diffstat:
M tpl/template.go | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
DIR diff --git a/tpl/template.go b/tpl/template.go
@@ -890,12 +890,20 @@ func Trim(a interface{}, b string) (string, error) {
}
// 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)
if err != nil {
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 {