diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-12 18:11:37 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-12 21:15:51 +0200 |
commit | 45c74526686f6a2afa02bcee767d837d6b9dd028 (patch) | |
tree | 22391738a5f8833fdc4592f97510298238e52332 /hugolib/page_output.go | |
parent | e765b43e2bf3d017f8ae8fd4d455d7bd60e11973 (diff) |
hugolib: Must recreate Paginator on live-reload
The structure may potentially have changed, and then it fails.
Fixes #3315
Diffstat (limited to 'hugolib/page_output.go')
-rw-r--r-- | hugolib/page_output.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/hugolib/page_output.go b/hugolib/page_output.go index 88e865c97..ea23dc203 100644 --- a/hugolib/page_output.go +++ b/hugolib/page_output.go @@ -78,13 +78,17 @@ func newPageOutput(p *Page, createCopy bool, f output.Format) (*PageOutput, erro // copy creates a copy of this PageOutput with the lazy sync.Once vars reset // so they will be evaluated again, for word count calculations etc. -func (p *PageOutput) copy() *PageOutput { - c, err := newPageOutput(p.Page, true, p.outputFormat) +func (p *PageOutput) copyWithFormat(f output.Format) (*PageOutput, error) { + c, err := newPageOutput(p.Page, true, f) if err != nil { - panic(err) + return nil, err } c.paginator = p.paginator - return c + return c, nil +} + +func (p *PageOutput) copy() (*PageOutput, error) { + return p.copyWithFormat(p.outputFormat) } func (p *PageOutput) layouts(layouts ...string) ([]string, error) { @@ -142,6 +146,9 @@ func (p *Page) Render(layout ...string) template.HTML { } p.pageOutputInit.Do(func() { + if p.mainPageOutput != nil { + return + } // If Render is called in a range loop, the page output isn't available. // So, create one. outFormat := p.outputFormats[0] |