hugolib: Fix layout lookup order for Render func - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit 08fa2b112407c1fe180e6c02dd8fe63735608336
(DIR) parent 6178238a0b069ae8ce65a23e3dd60c091de0cfef
(HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sun, 19 Mar 2017 11:40:54 +0100
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.
Diffstat:
M hugolib/page.go | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/hugolib/page.go b/hugolib/page.go
@@ -657,8 +657,8 @@ func (p *Page) Section() string {
}
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 @@ func (p *Page) Menus() PageMenus {
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...)
}