Skip to content

Commit

Permalink
tpl/partials: Remove superflous loop
Browse files Browse the repository at this point in the history
No need to check the themes template prefix.
  • Loading branch information
bep committed Jul 31, 2018
1 parent f219ac0 commit 0afa289
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions tpl/partials/partials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0afa289

Please sign in to comment.