1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Template library: default formatters
15 // StringFormatter formats into the default string representation.
16 // It is stored under the name "str" and is the default formatter.
17 // You can override the default formatter by storing your default
18 // under the name "" in your custom formatter map.
19 func StringFormatter(w io.Writer, value interface{}, format string) {
20 if b, ok := value.([]byte); ok {
28 esc_quot = []byte(""") // shorter than """
29 esc_apos = []byte("'") // shorter than "'"
30 esc_amp = []byte("&")
31 esc_lt = []byte("<")
32 esc_gt = []byte(">")
35 // HTMLEscape writes to w the properly escaped HTML equivalent
36 // of the plain text data s.
37 func HTMLEscape(w io.Writer, s []byte) {
62 // HTMLFormatter formats arbitrary values for HTML
63 func HTMLFormatter(w io.Writer, value interface{}, format string) {
64 b, ok := value.([]byte)
67 fmt.Fprint(&buf, value)