mirror of
https://github.com/golang/go
synced 2024-11-18 14:14:46 -07:00
allow nil user map
R=r DELTA=5 (3 added, 0 deleted, 2 changed) OCL=27371 CL=27389
This commit is contained in:
parent
a9996d0f89
commit
4011733d3c
@ -48,6 +48,7 @@ const (
|
|||||||
|
|
||||||
// FormatterMap is the type describing the mapping from formatter
|
// FormatterMap is the type describing the mapping from formatter
|
||||||
// names to the functions that implement them.
|
// names to the functions that implement them.
|
||||||
|
// TODO(rsc): Maybe func should take interface{} instead?
|
||||||
type FormatterMap map[string] func(reflect.Value) string
|
type FormatterMap map[string] func(reflect.Value) string
|
||||||
|
|
||||||
// Built-in formatters.
|
// Built-in formatters.
|
||||||
@ -446,9 +447,11 @@ func (t *template) evalVariable(name_formatter string) string {
|
|||||||
}
|
}
|
||||||
val := t.varValue(name);
|
val := t.varValue(name);
|
||||||
// is it in user-supplied map?
|
// is it in user-supplied map?
|
||||||
|
if t.fmap != nil {
|
||||||
if fn, ok := t.fmap[formatter]; ok {
|
if fn, ok := t.fmap[formatter]; ok {
|
||||||
return fn(val)
|
return fn(val)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// is it in builtin map?
|
// is it in builtin map?
|
||||||
if fn, ok := builtins[formatter]; ok {
|
if fn, ok := builtins[formatter]; ok {
|
||||||
return fn(val)
|
return fn(val)
|
||||||
|
Loading…
Reference in New Issue
Block a user