URI: 
       tpl: Factor out double Lookup in executeTemplate - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 8ddd95e3614718b5ff335fe484c451ca45b9a345
   DIR parent 474eb454dfb6e150d0a7a79edf32906f7a2355d8
  HTML Author: Cameron Moore <moorereason@gmail.com>
       Date:   Wed, 12 Oct 2016 01:26:39 -0500
       
       tpl: Factor out double Lookup in executeTemplate
       
       
       Diffstat:
         M tpl/template.go                     |      18 ++++++++----------
       
       1 file changed, 8 insertions(+), 10 deletions(-)
       ---
   DIR diff --git 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