hugolib: Handle any errors in processShortcodes - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit e951d65771ca299aa899e91bfe00411a5ada8f19
DIR parent 2bcbf104006e0ec03be4fd500f2519301d460f8c
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sat, 6 May 2017 10:48:27 +0200
hugolib: Handle any errors in processShortcodes
Diffstat:
M hugolib/handler_page.go | 8 ++++++--
M hugolib/page.go | 9 +++++++--
2 files changed, 13 insertions(+), 4 deletions(-)
---
DIR diff --git a/hugolib/handler_page.go b/hugolib/handler_page.go
@@ -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.
DIR diff --git a/hugolib/page.go b/hugolib/page.go
@@ -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 {