mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
tpl/partials: Remove superflous loop
No need to check the themes template prefix.
This commit is contained in:
parent
f219ac09f6
commit
0afa2897a0
1 changed files with 21 additions and 22 deletions
|
@ -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 {
|
||||
// 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 {
|
||||
b := bp.GetBuffer()
|
||||
defer bp.PutBuffer(b)
|
||||
|
||||
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 s, nil
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue