-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
global data is not passed to liquidjs as globals #1541
Comments
I’m not a Liquid expert, so don’t quote me on this, but I believe this is intended. The documentation on render states:
My understanding of this is that by definition, {% render "foo.html", bar: bar %} Edit: If you would like to circumvent that issue, I believe you could use the deprecated include tag which does share scopes between the parent and the child templates. The 11ty docs use |
@hugogiraudel thanks, I've seen that in the docs. I guess this is really a question of whether eleventy's global data should be passed down as liquidjs's global data. |
Per the LiquidJS docs on passing variables to
I believe this issue as @binyamin originally posted is valid: Eleventy globals (like |
A practical use case to show why this matters. In my blog post, I want to render a partial that will render an embedded view of an item from my {% # some-post.md %}
This is a toot I wrote:
{% render embedded-note fileSlug: 'abc123' %} Inside embedded-note.liquid, I'd like to find the item and render it: {% # embedded-note.liquid %}
{% assign note = collections.note | where 'fileSlug', fileSlug | first %}
<div>{{ note.templateContent }}</div> This will not currently work, because the partial does not have access to the global Instead, I must currently pass down the {% # some-post.md %}
This is a toot I wrote:
{% render embedded-note fileSlug: 'abc123', collections: collections %} Having to list all the globals your partial uses is tedious and messy. Given that LiquidJS has a supported concept of globals that are accessible to all partials, I think Eleventy should use it. |
Describe the bug
With
{% render layout.html %}
, you can only access a variable if it's defined in the included template/partial or passed down to liquid vialiquidOptions.globals
. 11ty refers to "global data", which is undefined within such partials.To Reproduce
See example repo
If you don't feel like running the example repo:
{% render %}
the include/partial.npx eleventy
Expected behavior
I expect that data which is the same for every page (eg.
pkg
,_data/**/*
) is passed down to liquid, whereas local variables are not.Environment:
Additional context
Related: harttle/liquidjs#185
The text was updated successfully, but these errors were encountered: