| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // Template library: default formatters |
| // StringFormatter formats into the default string representation. |
| // 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, format string, value ...interface{}) { |
| if b, ok := value[0].([]byte); ok { |
| esc_quot = []byte(""") // shorter than """ |
| esc_apos = []byte("'") // shorter than "'" |
| esc_amp = []byte("&") |
| // HTMLEscape writes to w the properly escaped HTML equivalent |
| // of the plain text data s. |
| func HTMLEscape(w io.Writer, s []byte) { |
| // HTMLFormatter formats arbitrary values for HTML |
| func HTMLFormatter(w io.Writer, format string, value ...interface{}) { |
| b, ok = value[0].([]byte) |
| fmt.Fprint(&buf, value...) |