mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
hugolib: Fix Render layouts for list pages
This commit is contained in:
parent
9a0aa5fdbe
commit
e49a2b83ad
1 changed files with 18 additions and 1 deletions
|
@ -102,12 +102,19 @@ func (p *PageOutput) layouts(layouts ...string) []string {
|
|||
}
|
||||
|
||||
func (p *PageOutput) Render(layout ...string) template.HTML {
|
||||
if !p.checkRender() {
|
||||
return template.HTML("")
|
||||
}
|
||||
|
||||
l := p.layouts(layout...)
|
||||
return p.s.Tmpl.ExecuteTemplateToHTML(p, l...)
|
||||
}
|
||||
|
||||
// TODO(bep) output
|
||||
func (p *Page) Render(layout ...string) template.HTML {
|
||||
if !p.checkRender() {
|
||||
return template.HTML("")
|
||||
}
|
||||
|
||||
p.pageOutputInit.Do(func() {
|
||||
// If Render is called in a range loop, the page output isn't available.
|
||||
// So, create one.
|
||||
|
@ -126,6 +133,16 @@ func (p *Page) Render(layout ...string) template.HTML {
|
|||
return p.mainPageOutput.Render(layout...)
|
||||
}
|
||||
|
||||
// We may fix this in the future, but the layout handling in Render isn't built
|
||||
// for list pages.
|
||||
func (p *Page) checkRender() bool {
|
||||
if p.Kind != KindPage {
|
||||
p.s.Log.ERROR.Printf(".Render only available for regular pages, not for %q of kind %q", p.Path(), p.Kind)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// OutputFormats holds a list of the relevant output formats for a given resource.
|
||||
type OutputFormats []*OutputFormat
|
||||
|
||||
|
|
Loading…
Reference in a new issue