2009-04-09 01:10:46 -06:00
|
|
|
// 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
|
|
|
|
|
|
|
|
package template
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt";
|
2009-04-13 20:29:23 -06:00
|
|
|
"io";
|
2009-04-09 01:10:46 -06:00
|
|
|
"reflect";
|
|
|
|
)
|
|
|
|
|
|
|
|
// HtmlFormatter formats arbitrary values for HTML
|
|
|
|
// TODO: do something for real.
|
2009-04-13 20:29:23 -06:00
|
|
|
func HtmlFormatter(w io.Write, value interface{}, format string) {
|
|
|
|
fmt.Fprint(w, value);
|
2009-04-09 01:10:46 -06:00
|
|
|
}
|
|
|
|
|
2009-04-14 01:06:49 -06:00
|
|
|
// StringFormatter formats into the default string representation.
|
2009-04-09 01:10:46 -06:00
|
|
|
// 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.
|
2009-04-13 20:29:23 -06:00
|
|
|
func StringFormatter(w io.Write, value interface{}, format string) {
|
|
|
|
fmt.Fprint(w, value);
|
2009-04-09 01:10:46 -06:00
|
|
|
}
|