From 0afa2897a0cf90f4348929ef432202efddc183a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 31 Jul 2018 11:27:50 +0200 Subject: tpl/partials: Remove superflous loop No need to check the themes template prefix. --- tpl/partials/partials.go | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'tpl') diff --git a/tpl/partials/partials.go b/tpl/partials/partials.go index 266329721..dba0e5013 100644 --- a/tpl/partials/partials.go +++ b/tpl/partials/partials.go @@ -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) -- cgit v1.2.3