mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 23:53:32 -05:00
hugolib: Handle any errors in processShortcodes
This commit is contained in:
parent
2bcbf10400
commit
e951d65771
2 changed files with 13 additions and 4 deletions
|
@ -79,7 +79,9 @@ func (h htmlHandler) PageConvert(p *Page) HandledResult {
|
||||||
// Work on a copy of the raw content from now on.
|
// Work on a copy of the raw content from now on.
|
||||||
p.createWorkContentCopy()
|
p.createWorkContentCopy()
|
||||||
|
|
||||||
p.ProcessShortcodes()
|
if err := p.processShortcodes(); err != nil {
|
||||||
|
return HandledResult{err: err}
|
||||||
|
}
|
||||||
|
|
||||||
return HandledResult{err: nil}
|
return HandledResult{err: nil}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +130,9 @@ func commonConvert(p *Page) HandledResult {
|
||||||
// Work on a copy of the raw content from now on.
|
// Work on a copy of the raw content from now on.
|
||||||
p.createWorkContentCopy()
|
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
|
// 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.
|
// process a page in isolation. See the new preRender func.
|
||||||
|
|
|
@ -1371,11 +1371,16 @@ func (p *Page) SaveSource() error {
|
||||||
return p.SaveSourceAs(p.FullFilePath())
|
return p.SaveSourceAs(p.FullFilePath())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Page) ProcessShortcodes() {
|
func (p *Page) processShortcodes() error {
|
||||||
p.shortcodeState = newShortcodeHandler()
|
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)
|
p.workContent = []byte(tmpContent)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Page) FullFilePath() string {
|
func (p *Page) FullFilePath() string {
|
||||||
|
|
Loading…
Reference in a new issue