From 4011733d3c6366a5b64bfec70e667554ce406aac Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Apr 2009 15:23:57 -0700 Subject: [PATCH] allow nil user map R=r DELTA=5 (3 added, 0 deleted, 2 changed) OCL=27371 CL=27389 --- src/lib/template/template.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/template/template.go b/src/lib/template/template.go index 1702889f4d..824b9d626b 100644 --- a/src/lib/template/template.go +++ b/src/lib/template/template.go @@ -48,6 +48,7 @@ const ( // FormatterMap is the type describing the mapping from formatter // names to the functions that implement them. +// TODO(rsc): Maybe func should take interface{} instead? type FormatterMap map[string] func(reflect.Value) string // Built-in formatters. @@ -446,8 +447,10 @@ func (t *template) evalVariable(name_formatter string) string { } val := t.varValue(name); // is it in user-supplied map? - if fn, ok := t.fmap[formatter]; ok { - return fn(val) + if t.fmap != nil { + if fn, ok := t.fmap[formatter]; ok { + return fn(val) + } } // is it in builtin map? if fn, ok := builtins[formatter]; ok { -- 2.48.1