Skip to content
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

Consider making GetMatch etc. smarter for bundled resources #4583

Closed
bep opened this issue Apr 6, 2018 · 13 comments
Closed

Consider making GetMatch etc. smarter for bundled resources #4583

bep opened this issue Apr 6, 2018 · 13 comments

Comments

@bep
Copy link
Member

bep commented Apr 6, 2018

See #4582

Which made this work:

{{ .Page.Parent.GetMatch "myimage*" }}

However, it would be nice if we could just do this in both cases:

{{ .Page.GetMatch "myimage*" }}

The bundled page does not have resources on its own and if it ever will, we can just expand the definition of GetMatch.

/cc @onedrawingperday

@bep bep added the Enhancement label Apr 6, 2018
@bep bep added this to the v0.39 milestone Apr 6, 2018
@bep
Copy link
Member Author

bep commented Apr 6, 2018

/cc @kaushalmodi @regisphilibert and gang

@kaushalmodi
Copy link
Contributor

I think {{ .Page.Parent.GetMatch "myimage*" }} is a better syntax. That allows people to understand that resources of page kind cannot have their own resources. Also the .Parent is useful for fetching other Parent page properties too (in case that's ever needed).

So instead of having 2 ways of doing the same thing, the .Page.Parent. .. method seems more versatile, and correct.

@bep
Copy link
Member Author

bep commented Apr 6, 2018

I think {{ .Page.Parent.GetMatch "myimage*" }} is a better syntax.

It is obviously there to stay.

But from a shortcode, there is currently no simple way to say "give me the resources in this bundle". I cannot always look in .Parent, so what do I do?

@regisphilibert
Copy link
Member

regisphilibert commented Apr 6, 2018

I tend to agree with @kaushalmodi here. By leaving the resources method on the .Parent, which is intuitively identified as the Page Bundle (mother of all resources), it avoids a complexification of the doc.

Those two informations are not intuitive and will have to be detailed in the doc.

  • Every page resources inherit the bundle resource methods (.Match, .GetMatch).
  • The .GetMatch path passed as attributes must be relative to the bundle rather than the page itself (which can be nested inside bundle structure).

The current state is very intuitive and doesn't need any explanation. Proof is that someone readily brought up #4582

@regisphilibert
Copy link
Member

regisphilibert commented Apr 6, 2018

But from a shortcode, there is currently no simple way to say "give me the resources in this bundle". I cannot always look in .Parent, so what do I do?

You mean $.Page.Parent.GetMatch would/does not work from a shortcode ?

@bep
Copy link
Member Author

bep commented Apr 6, 2018

You mean $.Page.Parent.GetMatch would not work from a shortcode ?

It works fine, but the shortcode then needs to know where to look. And that is currently impossible. From index.md it should not look in .Parent (it would potentially get some totally different images).

@regisphilibert
Copy link
Member

Yes I get it now.

Even if we were to add a special test function for that we shouldn't have to add the following for every shortcode needing resources.

{{ if .HasParent }}
{{ $.Page.Parent.GetMatch }}
{{ else }}
{{ $.Page.GetMatch }}

So yes I agree this is needed, thanks for clarifying.

@kaushalmodi
Copy link
Contributor

And that is currently impossible. From index.md it should not look in .Parent (it would potentially get some totally different images).

Makes sense. Then we need to make sure that the documentation of .GetMatch and everything that gets affected with this change is updated.

@regisphilibert
Copy link
Member

regisphilibert commented Apr 6, 2018

I wanted to write my comment in #4582 but as it has been closed.

But if I understand correctly to get a parent section we now need to use (from a page resource) .Parent.Parent.Title ?

We will also have to update Page Variable's .Parent definition:

A section’s parent section or a page’s section.

I'd rather we introduced a new dedicated Page Variable called something like .Bundle but it is too late as I understand.

@bep
Copy link
Member Author

bep commented Apr 6, 2018

Sorry but I juste realised what .Parent is.

What .Parent was. It is the page's parent page, but up until now that has been either 1) a section or 2) the home page.

@regisphilibert
Copy link
Member

regisphilibert commented Apr 6, 2018

I see, as long as a given page is included in another's page .Data.Pages collection, such parent page is referred to, in the page context, as .Parent.

For a page resource though, the logic is a bit different, as .Parent refers to its Page Bundle's index.md.

I think it is a bit confusing that a page resource follows the same "family line" as conventional pages. But I cannot come up with any problematic scenario.

So I'll concede it's just a matter of updating the doc :)

@bep
Copy link
Member Author

bep commented Apr 6, 2018

I think it is a bit confusing that a page resource follows the same "family line"

Maybe, but I think it would be even more confusing if we invented .SomeOtherParent concept.

@bep bep modified the milestones: v0.39, v0.40 Apr 9, 2018
@bep bep modified the milestones: v0.40, v0.41 Apr 20, 2018
@bep bep modified the milestones: v0.41, v0.42 May 4, 2018
@bep bep modified the milestones: v0.42, v0.43 Jun 5, 2018
@bep bep modified the milestones: v0.43, v0.44 Jun 30, 2018
@bep bep modified the milestones: v0.44, v0.45, v0.46 Jul 10, 2018
@bep bep modified the milestones: v0.46, v0.47 Aug 3, 2018
@bep bep added this to the v0.112.0 milestone Feb 15, 2023
@bep bep modified the milestones: v0.112.0, v0.113.0 Apr 15, 2023
@bep bep modified the milestones: v0.113.0, v0.114.0, v0.115.0 Jun 8, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep closed this as completed Jan 31, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants