ref: 08fa2b112407c1fe180e6c02dd8fe63735608336
parent: 6178238a0b069ae8ce65a23e3dd60c091de0cfef
author: Bjørn Erik Pedersen <[email protected]>
date: Sun Mar 19 07:40:54 EDT 2017
hugolib: Fix layout lookup order for Render func Will have to fix this in a better way later in relation to the non-renderable pages. But this commit brings the Hugo Benchmark down to "only slightly slower" than master. ``` benchmark old ns/op new ns/op delta BenchmarkHugo-4 10074504521 10071236251 -0.03% benchmark old allocs new allocs delta BenchmarkHugo-4 43623091 49271859 +12.95% benchmark old bytes new bytes delta BenchmarkHugo-4 9468322704 9725848376 +2.72% ``` Which is something we can work with.
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -657,8 +657,8 @@
}
func (p *Page) layouts(layouts ...string) []string {
- // TODO(bep) output
- if len(p.layoutsCalculated) > 0 {
+ // TODO(bep) output the logic here needs to be redone.
+ if len(layouts) == 0 && len(p.layoutsCalculated) > 0 {
return p.layoutsCalculated
}
@@ -1285,9 +1285,8 @@
return p.pageMenus
}
-func (p *Page) Render(layouts ...string) template.HTML {
- l := p.layouts(layouts...)
-
+func (p *Page) Render(layout ...string) template.HTML {
+ l := p.layouts(layout...)
return p.s.Tmpl.ExecuteTemplateToHTML(p, l...)
}