hugolib: Handle any errors in processShortcodes

This commit is contained in:
Bjørn Erik Pedersen 2017-05-06 10:48:27 +02:00
parent 2bcbf10400
commit e951d65771
2 changed files with 13 additions and 4 deletions

View file

@ -79,7 +79,9 @@ func (h htmlHandler) PageConvert(p *Page) HandledResult {
// Work on a copy of the raw content from now on.
p.createWorkContentCopy()
p.ProcessShortcodes()
if err := p.processShortcodes(); err != nil {
return HandledResult{err: err}
}
return HandledResult{err: nil}
}
@ -128,7 +130,9 @@ func commonConvert(p *Page) HandledResult {
// Work on a copy of the raw content from now on.
p.createWorkContentCopy()
p.ProcessShortcodes()
if err := p.processShortcodes(); err != nil {
return HandledResult{err: err}
}
// TODO(bep) these page handlers need to be re-evaluated, as it is hard to
// process a page in isolation. See the new preRender func.

View file

@ -1371,11 +1371,16 @@ func (p *Page) SaveSource() error {
return p.SaveSourceAs(p.FullFilePath())
}
func (p *Page) ProcessShortcodes() {
func (p *Page) processShortcodes() error {
p.shortcodeState = newShortcodeHandler()
tmpContent, _ := p.shortcodeState.extractAndRenderShortcodes(string(p.workContent), p)
tmpContent, err := p.shortcodeState.extractAndRenderShortcodes(string(p.workContent), p)
if err != nil {
return err
}
p.workContent = []byte(tmpContent)
return nil
}
func (p *Page) FullFilePath() string {