Please sign in to comment.
Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour was undefined. Note that this has never been an issue from regular templates. It will still not be possible to get **the current shortcode's page's rendered content**. That would have impressed Einstein. The new and well defined rules are: * `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values. * For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below. * `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged) If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information. Fixes #4632 Fixes #4653 Fixes #4655
- Loading branch information...
Showing with 392 additions and 153 deletions.
- +10 −0 deps/deps.go
- +3 −0 helpers/content.go
- +1 −0 hugolib/config.go
- +1 −1 hugolib/embedded_shortcodes_test.go
- +11 −26 hugolib/hugo_sites.go
- +1 −0 hugolib/hugo_sites_build.go
- +28 −5 hugolib/hugo_sites_build_test.go
- +176 −67 hugolib/page.go
- +1 −1 hugolib/pageSort.go
- +2 −2 hugolib/pageSort_test.go
- +4 −0 hugolib/page_bundler_handlers.go
- +20 −5 hugolib/page_bundler_test.go
- +17 −16 hugolib/page_test.go
- +67 −0 hugolib/page_without_content.go
- +26 −18 hugolib/shortcode.go
- +11 −3 hugolib/shortcode_test.go
- +9 −8 hugolib/site.go
- +4 −1 hugolib/site_render.go
Oops, something went wrong.