mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-24 14:14:47 +00:00
Allow partial without .html
`partial "header" .` means the same thing as `partial "header.html" .`.
This commit is contained in:
parent
266511b6d3
commit
d7e6e490c2
1 changed files with 9 additions and 3 deletions
|
@ -563,10 +563,16 @@ func ExecuteTemplate(context interface{}, layouts ...string) *bytes.Buffer {
|
||||||
buffer := new(bytes.Buffer)
|
buffer := new(bytes.Buffer)
|
||||||
worked := false
|
worked := false
|
||||||
for _, layout := range layouts {
|
for _, layout := range layouts {
|
||||||
if localTemplates.Lookup(layout) != nil {
|
name := layout
|
||||||
err := localTemplates.ExecuteTemplate(buffer, layout, context)
|
|
||||||
|
if localTemplates.Lookup(name) == nil {
|
||||||
|
name = layout + ".html"
|
||||||
|
}
|
||||||
|
|
||||||
|
if localTemplates.Lookup(name) != nil {
|
||||||
|
err := localTemplates.ExecuteTemplate(buffer, name, context)
|
||||||
if 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