hugo/hugolib
Bjørn Erik Pedersen 4d26ab33dc
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
2018-04-21 22:02:56 +02:00
..
pagemeta Refactor the GitInfo into the date handlers 2018-03-11 21:32:05 +01:00
testdata hugolib: Add test for image processing from shortcodes 2018-01-01 12:11:36 +01:00
testsite/content Refactor the GitInfo into the date handlers 2018-03-11 21:32:05 +01:00
404_test.go Spring test cleaning, take 2 2018-03-18 09:54:32 +01:00
alias.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
alias_test.go Spring test cleaning, take 2 2018-03-18 09:54:32 +01:00
author.go
case_insensitive_test.go Allow themes to define output formats, media types and params 2018-03-21 09:22:19 +01:00
config.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
config_test.go Allow themes to define output formats, media types and params 2018-03-21 09:22:19 +01:00
datafiles_test.go hugolib: Test cleaning #1 2018-03-17 18:59:07 +01:00
disableKinds_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
embedded_shortcodes_test.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
fileInfo.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
gitinfo.go Refactor the GitInfo into the date handlers 2018-03-11 21:32:05 +01:00
hugo_info.go Make ge, le etc. work with the Hugo Version number 2018-02-22 09:15:12 +01:00
hugo_info_test.go Make ge, le etc. work with the Hugo Version number 2018-02-22 09:15:12 +01:00
hugo_sites.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
hugo_sites_build.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
hugo_sites_build_failures_test.go hugolib: Fix freeze in invalid front matter error case 2018-03-24 10:06:58 +01:00
hugo_sites_build_test.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
hugo_sites_multihost_test.go Spring test cleaning, take 2 2018-03-18 09:54:32 +01:00
language_content_dir_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
media.go
menu.go hugolib: Remove unused code 2018-01-25 17:14:03 +01:00
menu_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
multilingual.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
page.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
page_bundler.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
page_bundler_capture.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
page_bundler_capture_test.go Fix two tests that are broken on Windows 2018-04-05 08:35:06 +02:00
page_bundler_handlers.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
page_bundler_test.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
page_collections.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
page_collections_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
page_output.go hugolib: Improve error message in .Render 2018-02-13 09:01:47 +01:00
page_paths.go hugolib: Extract date and slug from filename 2018-03-11 18:26:18 +01:00
page_paths_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
page_permalink_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
page_resource.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
page_taxonomy_test.go hugolib: Do not tolower result from Page.GetParam 2017-12-29 08:58:38 +01:00
page_test.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
page_time_integration_test.go all: Update textual references in Go source to point to gohugoio/hugo 2017-06-13 18:47:17 +02:00
page_without_content.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
pageCache.go Add a way to merge pages by language 2018-03-16 10:10:01 +01:00
pageCache_test.go Add a way to merge pages by language 2018-03-16 10:10:01 +01:00
pageGroup.go hugolib: Do not tolower result from Page.GetParam 2017-12-29 08:58:38 +01:00
pageGroup_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pages_language_merge.go Add a way to merge pages by language 2018-03-16 10:10:01 +01:00
pages_language_merge_test.go Add language merge support for Pages in resource.Resources 2018-04-19 16:23:00 +02:00
pages_related.go hugolib: Fix typo in aquired 2017-09-07 16:21:33 +02:00
pages_related_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pageSort.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
pageSort_test.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
pagesPrevNext.go hugolib: Simplify Prev/Next 2018-03-12 22:13:25 +01:00
pagesPrevNext_test.go
pagination.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pagination_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
path_separators_test.go hugolib, output: Incorporate suffix and type in layout resolve 2017-03-27 15:43:56 +02:00
permalinker.go hugolib: Add optional outputFormat to Ref/RelRef 2017-04-04 23:09:01 +02:00
permalinks.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
permalinks_test.go
prune_resources.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
robotstxt_test.go Spring test cleaning, take 2 2018-03-18 09:54:32 +01:00
rss_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
scratch.go hugolib: Add Reset method to delete key from Scratch 2018-03-17 00:13:23 +01:00
scratch_test.go hugolib: Add Reset method to delete key from Scratch 2018-03-17 00:13:23 +01:00
shortcode.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
shortcode_test.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
shortcodeparser.go Allow "*/" inside commented out shortcodes 2018-04-11 22:41:48 +02:00
shortcodeparser_test.go Allow "*/" inside commented out shortcodes 2018-04-11 22:41:48 +02:00
site.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
site_benchmark_test.go Add a GetPage to the site benchmarks 2018-01-24 09:08:26 +01:00
site_output.go Allow partial redefinition of the ouputs config 2018-03-10 16:57:25 +01:00
site_output_test.go Allow partial redefinition of the ouputs config 2018-03-10 16:57:25 +01:00
site_render.go Make .Content (almost) always available in shortcodes 2018-04-21 22:02:56 +02:00
site_sections.go hugolib: Avoid scanning entire site to find the home 2018-02-25 10:50:44 +01:00
site_sections_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
site_stats_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
site_test.go Add a way to merge pages by language 2018-03-16 10:10:01 +01:00
site_url_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
siteJSONEncode_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
sitemap.go
sitemap_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
taxonomy.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
taxonomy_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
template_engines_test.go Fix broken shortcodes for Ace and Amber 2017-11-18 10:41:31 +01:00
template_test.go hugolib: Add additional test to TestTemplateLookupOrder 2018-02-05 08:38:04 +01:00
testhelpers_test.go Add support for a content dir set per language 2018-04-02 08:06:21 +02:00
translations.go hugolib: Fix .IsTranslated with identical filenames 2017-11-17 19:46:32 +01:00