From: Cameron Moore Date: Wed, 12 Oct 2016 06:26:39 +0000 (-0500) Subject: tpl: Factor out double Lookup in executeTemplate X-Git-Tag: v0.18~202 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8ddd95e3614718b5ff335fe484c451ca45b9a345;p=brevno-suite%2Fhugo tpl: Factor out double Lookup in executeTemplate --- diff --git a/tpl/template.go b/tpl/template.go index 47929897..431ea5a2 100644 --- a/tpl/template.go +++ b/tpl/template.go @@ -117,19 +117,17 @@ func partial(name string, contextList ...interface{}) template.HTML { } func executeTemplate(context interface{}, w io.Writer, layouts ...string) { - worked := false + var worked bool for _, layout := range layouts { - - name := layout - - if Lookup(name) == nil { - name = layout + ".html" + templ := Lookup(layout) + if templ == nil { + layout += ".html" + templ = Lookup(layout) } - if templ := Lookup(name); templ != nil { - err := templ.Execute(w, context) - if err != nil { - jww.ERROR.Println(err, "in", name) + if templ != nil { + if err := templ.Execute(w, context); err != nil { + jww.ERROR.Println(err, "in", layout) } worked = true break