tpl/partials: Remove superflous loop
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 31 Jul 2018 09:27:50 +0000 (11:27 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 31 Jul 2018 11:28:15 +0000 (13:28 +0200)
No need to check the themes template prefix.

tpl/partials/partials.go

index 266329721403d53e49599b1a27de89aa975650dc..dba0e50139b5ea9a188dff8f3b1048896e6cb2ee 100644 (file)
@@ -74,36 +74,35 @@ func (ns *Namespace) Include(name string, contextList ...interface{}) (interface
                context = contextList[0]
        }
 
-       for _, n := range []string{"partials/" + name, "theme/partials/" + name} {
-               templ, found := ns.deps.Tmpl.Lookup(n)
+       n := "partials/" + name
+       templ, found := ns.deps.Tmpl.Lookup(n)
 
-               if !found {
-                       // For legacy reasons.
-                       templ, found = ns.deps.Tmpl.Lookup(n + ".html")
-               }
-               if found {
-                       b := bp.GetBuffer()
-                       defer bp.PutBuffer(b)
-
-                       if err := templ.Execute(b, context); err != nil {
-                               return "", err
-                       }
+       if !found {
+               // For legacy reasons.
+               templ, found = ns.deps.Tmpl.Lookup(n + ".html")
+       }
+       if found {
+               b := bp.GetBuffer()
+               defer bp.PutBuffer(b)
 
-                       if _, ok := templ.(*texttemplate.Template); ok {
-                               s := b.String()
-                               if ns.deps.Metrics != nil {
-                                       ns.deps.Metrics.TrackValue(n, s)
-                               }
-                               return s, nil
-                       }
+               if err := templ.Execute(b, context); err != nil {
+                       return "", err
+               }
 
+               if _, ok := templ.(*texttemplate.Template); ok {
                        s := b.String()
                        if ns.deps.Metrics != nil {
                                ns.deps.Metrics.TrackValue(n, s)
                        }
-                       return template.HTML(s), nil
+                       return s, nil
+               }
 
+               s := b.String()
+               if ns.deps.Metrics != nil {
+                       ns.deps.Metrics.TrackValue(n, s)
                }
+               return template.HTML(s), nil
+
        }
 
        return "", fmt.Errorf("Partial %q not found", name)