mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
tpl: Factor out double Lookup in executeTemplate
This commit is contained in:
parent
474eb454df
commit
8ddd95e361
1 changed files with 8 additions and 10 deletions
|
@ -117,19 +117,17 @@ func partial(name string, contextList ...interface{}) template.HTML {
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeTemplate(context interface{}, w io.Writer, layouts ...string) {
|
func executeTemplate(context interface{}, w io.Writer, layouts ...string) {
|
||||||
worked := false
|
var worked bool
|
||||||
for _, layout := range layouts {
|
for _, layout := range layouts {
|
||||||
|
templ := Lookup(layout)
|
||||||
name := layout
|
if templ == nil {
|
||||||
|
layout += ".html"
|
||||||
if Lookup(name) == nil {
|
templ = Lookup(layout)
|
||||||
name = layout + ".html"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if templ := Lookup(name); templ != nil {
|
if templ != nil {
|
||||||
err := templ.Execute(w, context)
|
if err := templ.Execute(w, context); err != nil {
|
||||||
if err != nil {
|
jww.ERROR.Println(err, "in", layout)
|
||||||
jww.ERROR.Println(err, "in", name)
|
|
||||||
}
|
}
|
||||||
worked = true
|
worked = true
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue