hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit e49a2b83ad9825a978ecbf0ff5fd9b7331690c17
parent 9a0aa5fdbe3ef35b7cc1dd756f54f1b219225bfc
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Sun, 26 Mar 2017 18:51:12 +0200

hugolib: Fix Render layouts for list pages

Diffstat:
Mhugolib/page_output.go | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/hugolib/page_output.go b/hugolib/page_output.go
@@ -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