diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-10 20:54:50 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-11 20:21:06 +0100 |
commit | 2f2ea42c091931fe4735e0ca7b37dc05cb8c044b (patch) | |
tree | ca1d5fa25acf4d955936c2f9f3f8536edca4176a /hugolib/page.go | |
parent | 5f443bd45bd63c10796fc340985fddf218c7ef0d (diff) |
hugolib: Fix reloading corner cases for shortcodes
This commit fixes two different, but related issues:
1) Live-reload when a new shortcode was defined in the content file before the shortcode itself was created.
2) Live-reload when a newly defined shortcode changed its "inner content" status.
This commit also improves the shortcode related error messages to include the full path to the content file in question.
Fixes #3156
Diffstat (limited to 'hugolib/page.go')
-rw-r--r-- | hugolib/page.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/hugolib/page.go b/hugolib/page.go index 5ee31c2a8..e23434a78 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -138,9 +138,7 @@ type Page struct { // whether the content is in a CJK language. isCJKLanguage bool - // shortcode state - contentShortCodes map[string]func() (string, error) - shortcodes map[string]shortcode + shortcodeState *shortcodeHandler // the content stripped for HTML plain string // TODO should be []byte @@ -1484,9 +1482,10 @@ func (p *Page) SaveSource() error { } func (p *Page) ProcessShortcodes() { - tmpContent, tmpContentShortCodes, _ := extractAndRenderShortcodes(string(p.workContent), p) + p.shortcodeState = newShortcodeHandler() + tmpContent, _ := p.shortcodeState.extractAndRenderShortcodes(string(p.workContent), p) p.workContent = []byte(tmpContent) - p.contentShortCodes = tmpContentShortCodes + } func (p *Page) FullFilePath() string { |