New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make .Content (almost) always available in shortcodes #4632

Closed
bep opened this Issue Apr 16, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@bep
Member

bep commented Apr 16, 2018

The timing issues here is esp. visible now with shortcodes and .Site.GetPage. There are chicken and egg situations, so perfect is hard. But we should do better.

@bep bep added this to the v0.39.1 milestone Apr 16, 2018

bep added a commit to bep/hugo that referenced this issue Apr 19, 2018

Improve .Content vs shortcodes
For the content from other pages in shortcodes there are some chicken and
egg dependencies that is hard to get around. But we can improve on this  by preparing the pages in a certain order:

 1. The headless pages goes first. These are page typically pages and images etc.
 2. Any leaf bundles goes next
 3. Regular single pages
 4. Branch bundles

Fixes gohugoio#4632

@bep bep added Enhancement and removed NeedsInvestigation labels Apr 19, 2018

@bep bep changed the title from Investigate possible .Site.GetPage vs shortcodes timing issue to Improve "page content in shortcodes" Apr 19, 2018

bep added a commit to bep/hugo that referenced this issue Apr 19, 2018

Improve .Content vs shortcodes
For the content from other pages in shortcodes there are some chicken and
egg dependencies that is hard to get around. But we can improve on this  by preparing the pages in a certain order:

 1. The headless pages goes first. These are page typically pages and images etc.
 2. Any leaf bundles goes next
 3. Regular single pages
 4. Branch bundles

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 19, 2018

Improve .Content vs shortcodes
For the content from other pages in shortcodes there are some chicken and
egg dependencies that is hard to get around. But we can improve on this  by preparing the pages in a certain order:

 1. The headless pages goes first. These are page typically pages and images etc.
 2. Any leaf bundles goes next
 3. Regular single pages
 4. Branch bundles

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 19, 2018

Improve .Content vs shortcodes
For the content from other pages in shortcodes there are some chicken and
egg dependencies that is hard to get around. But we can improve on this  by preparing the pages in a certain order:

 1. The headless bundles goes first. These are page typically page and image collections..
 2. Leaf bundles
 3. Regular single pages
 4. Branch bundles

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 19, 2018

Improve .Content vs shortcodes
For the content from other pages in shortcodes there are some chicken and
egg dependencies that is hard to get around. But we can improve on this  by preparing the pages in a certain order:

 1. The headless bundles goes first. These are page typically page and image collections..
 2. Leaf bundles
 3. Regular single pages
 4. Branch bundles

Fixes gohugoio#4632

@bep bep closed this in e590cc2 Apr 19, 2018

bep added a commit that referenced this issue Apr 19, 2018

hugolib: Prepare child page resources before the page itself
To make sure that the child resources' content is ready before any shortcode is processed in their owner.

See #4632

@bep bep added Bug and removed Enhancement labels Apr 19, 2018

@bep

This comment has been minimized.

Member

bep commented Apr 19, 2018

Will take another stab at this.

@bep bep reopened this Apr 19, 2018

bep added a commit to bep/hugo that referenced this issue Apr 19, 2018

Make Page.Content and related lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes.

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content and related lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes.

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content and related lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes.

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

@bep bep modified the milestones: v0.39.1, v0.40 Apr 20, 2018

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` there to use as long as you don't have infinite content recursion in your shortcode/content setup. See below.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` there to use as long as you don't have infinite content recursion in your shortcode/content setup. See below.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.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.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.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.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.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.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple 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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been 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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been 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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been 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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been 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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been 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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

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 gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

@bep bep closed this in #4651 Apr 21, 2018

bep added a commit to bep/hugo that referenced this issue Apr 22, 2018

hugolib: Init the content and shortcodes early
In most cases we could delay the content init until rendering time, but there could be use cases where the templates would depend on state set in the shortcodes (.Page.Scratch.Set), so we  need to do this early.

See gohugoio#4632

bep added a commit that referenced this issue Apr 22, 2018

hugolib: Init the content and shortcodes early
In most cases we could delay the content init until rendering time, but there could be use cases where the templates would depend on state set in the shortcodes (.Page.Scratch.Set), so we  need to do this early.

See #4632

bep added a commit to bep/hugo that referenced this issue Apr 24, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664

bep added a commit to bep/hugo that referenced this issue Apr 24, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664

bep added a commit to bep/hugo that referenced this issue Apr 24, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664

bep added a commit to bep/hugo that referenced this issue Apr 24, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664

bep added a commit to bep/hugo that referenced this issue Apr 25, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664

bep added a commit to bep/hugo that referenced this issue Apr 25, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664

bep added a commit to bep/hugo that referenced this issue Apr 25, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664

bep added a commit to bep/hugo that referenced this issue Apr 25, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664

bep added a commit to bep/hugo that referenced this issue Apr 25, 2018

hugolib: Fix some shortcode vs .Content corner cases
This is a follow-up to gohugoio#4632. There were some assumptions in that implementation that did not hold water in all situations.

This commit simplifies the content lazy initalization making it more robust.

Fixes gohugoio#4664
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment