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.
This commit is contained in:
Bjørn Erik Pedersen 2017-03-19 11:40:54 +01:00
parent 6178238a0b
commit 08fa2b1124

View file

@ -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...)
}