From 08fa2b112407c1fe180e6c02dd8fe63735608336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 19 Mar 2017 11:40:54 +0100 Subject: [PATCH] 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. --- hugolib/page.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hugolib/page.go b/hugolib/page.go index 1308aa49d..2f21eb313 100644 --- 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...) }