mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
hugolib: Fix Render layouts for list pages
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user