mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
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
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user