Open AleksandrHovhannisyan opened 2 years ago
I’m also experiencing this same issue with accessing global and page data using:
{% render “partial.html” %}
Related (i.e. can be extended to include this): https://github.com/11ty/eleventy/pull/3212
Describe the bug
Per the Liquidjs docs, the {% include %} tag is deprecated and it's recommended that we use the {% render %} tag instead. See also: https://github.com/11ty/eleventy/issues/2411. Unfortunately, while it's currently possible to use the
{% render %}
tag in 11ty, it's not possible to access globals or global data from within the rendered template. Per the Liquid docs on render:However, the section on passing in arguments to the rendered template clarifies that globals should be accessible:
The
LiquidOptions
interface does have aglobals
config here: https://github.com/harttle/liquidjs/blob/01029aba87e9a40ce104cdd9b8228170f345792c/src/liquid-options.ts#L65-L66. And 11ty supports configuring Liquid options viaeleventyConfig.setLiquidOptions
.Unfortunately, there is no way to pass along 11ty global data and the page variable because these are not accessible from the
.eleventy.js
config as far as I can tell. How do I proceed?To Reproduce Steps to reproduce the behavior:
yarn
to install 11ty, the only dependency.yarn serve
to start the server.render
ed partial is accessible within the partial, as expected.page
variable is not accessible within the partial (unexpected)..eleventy.js
src/_includes/partial.html
src/index.html
Expected behavior It should be possible to access 11ty data and page data from within a
render
ed partial sincerender
is the recommended tag for rendering partials in Liquid.Observed behavior
page
is undefined inside arender
ed partial.Environment:
Additional context
https://github.com/11ty/eleventy/issues/2411
NOTE: It is possible to work around this issue by passing in the necessary information as arguments. But I'm wondering if there's a way to avoid having to do that.