mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
25d645f47a
When a template calls the .Translations function and a Hugo environment is using multiple output formats, a template that calls methods like .Summary and .Len on each translation will unexpectedly show empty return values for these methods. This is because each pageOutput's ContentProvider is assigned to a page.NopPage in newPageOutput. When *HugoSites.render assigns pageContentOutputs to pageOutputs in *pageState.shiftToOutputFormat, it reuses pageContentOutputs from other pageOutputs, leaving some pageContentOutputs as NopPages. While this approach conserves resources, sometimes it means that a template will unexpectedly call a method on a pageContentOutput that is actually a NopPage. In the case of ContentProvider methods called on translations for alternative output formats, the methods were called on NopPages. This change introduces LazyContentProvider, which performs late initialization when one of its methods is called. This way, we can reuse content in "normal" cases but ensure that ContentProvider methods work as expected when a pageOutput is not assigned a pageContentOutput during the initial pre-render phase. Fixes #8919 |
||
---|---|---|
.. | ||
page_generate | ||
pagemeta | ||
page.go | ||
page_author.go | ||
page_data.go | ||
page_data_test.go | ||
page_kinds.go | ||
page_kinds_test.go | ||
page_lazy_contentprovider.go | ||
page_marshaljson.autogen.go | ||
page_matcher.go | ||
page_matcher_test.go | ||
page_nop.go | ||
page_outputformat.go | ||
page_paths.go | ||
page_paths_test.go | ||
page_wrappers.autogen.go | ||
pagegroup.go | ||
pagegroup_test.go | ||
pages.go | ||
pages_cache.go | ||
pages_cache_test.go | ||
pages_language_merge.go | ||
pages_prev_next.go | ||
pages_prev_next_test.go | ||
pages_related.go | ||
pages_related_test.go | ||
pages_sort.go | ||
pages_sort_search.go | ||
pages_sort_search_test.go | ||
pages_sort_test.go | ||
pages_test.go | ||
pagination.go | ||
pagination_test.go | ||
permalinks.go | ||
permalinks_test.go | ||
site.go | ||
testhelpers_test.go | ||
weighted.go | ||
zero_file.autogen.go |