summaryrefslogtreecommitdiffstats
path: root/libgo/go/template/format.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/template/format.go')
-rw-r--r--libgo/go/template/format.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/libgo/go/template/format.go b/libgo/go/template/format.go
index 8a31de970a3..9156b080816 100644
--- a/libgo/go/template/format.go
+++ b/libgo/go/template/format.go
@@ -16,12 +16,14 @@ import (
// It is stored under the name "str" and is the default formatter.
// You can override the default formatter by storing your default
// under the name "" in your custom formatter map.
-func StringFormatter(w io.Writer, value interface{}, format string) {
- if b, ok := value.([]byte); ok {
- w.Write(b)
- return
+func StringFormatter(w io.Writer, format string, value ...interface{}) {
+ if len(value) == 1 {
+ if b, ok := value[0].([]byte); ok {
+ w.Write(b)
+ return
+ }
}
- fmt.Fprint(w, value)
+ fmt.Fprint(w, value...)
}
var (
@@ -60,11 +62,15 @@ func HTMLEscape(w io.Writer, s []byte) {
}
// HTMLFormatter formats arbitrary values for HTML
-func HTMLFormatter(w io.Writer, value interface{}, format string) {
- b, ok := value.([]byte)
+func HTMLFormatter(w io.Writer, format string, value ...interface{}) {
+ ok := false
+ var b []byte
+ if len(value) == 1 {
+ b, ok = value[0].([]byte)
+ }
if !ok {
var buf bytes.Buffer
- fmt.Fprint(&buf, value)
+ fmt.Fprint(&buf, value...)
b = buf.Bytes()
}
HTMLEscape(w, b)
OpenPOWER on IntegriCloud