diff --git a/template.go b/template.go index a24b614..7a91b26 100644 --- a/template.go +++ b/template.go @@ -401,7 +401,7 @@ var VariablesMap map[string]bool = map[string]bool{ func (a *Article) renderTemplateMagic(name string, params map[string]string) string { renderer, ok := MagicMap[name] text := "" - if ok { + if ok && renderer != nil { text = renderer(name, params) } diff --git a/template_test.go b/template_test.go index a2f8ebf..fd4ace4 100644 --- a/template_test.go +++ b/template_test.go @@ -54,3 +54,18 @@ func TestMagicMap(t *testing.T) { t.Error("Error in magic map ", l) } } + +func TestNilFunc(t *testing.T) { + mw := "{{DISPLAYTITLE}}" + t.Log(mw) + + a, err := ParseArticle("Test", mw, &DummyPageGetter{}) + if err != nil { + t.Error("Error:", err) + } + + l := a.GetText() + if strings.TrimSpace(l) != "" { + t.Error("NIL entry in magic map not caught", l) + } +}