-
-
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
Shortcode arguments not passed correctly when called from liquid layout #2348
Comments
Interesting. I can reproduce in 1.0.0 and 1.0.1 when using a smaller test case: https://github.com/pdehaan/11ty-2348 But it only seems to happen when using Liquid, and only from a layout file. If I use the shortcode directly in my template it seems to pass all attributes. |
I'm experiencing the same issue and was banging my head against the desk trying to figure out why my shortcode worked on one page, and different variables would be display as "undefined" on rendered pages that used the exact same data. Turns out it was exactly the behavior @pdehaan described. The variables are passed through correctly on page files, but get lost when the shortcode is called on a layout file. With a bit more playing around, I discovered that shortcode will work in layout files if its in an include file, so a hacky work around is to move your shortcode call into an include file and call the include from your layout file. _layouts/myLayout.html
_includes/myshortcode.html
|
We just ran into this and are seeing random invocations of the same shortcode get variables passed in as On eleventy 1.0.1 and also doesn't work on 2.0.0-canary.8 |
Did some digging and looks like duplicate of #2154 |
Fixed by #2367. Thank you @epelc! Release versions here: #2367 (comment) |
Hello
Thank you for this great tool, we do good and things with it (social and environmental) and I have a lot of fun 🙏
Describe the bug
When using shortcodes in liquid, the parameters are not passed correctly to the js function
To Reproduce
Then in another terminal window
In
.eleventy.js
I add this line:eleventyConfig.addShortcode("image", (...args) => console.log('image', args));
The output at this stage is correct:
In
posts/firstpost.md
I set layout tolayouts/post.liquid
, then the output is still correctFinally in
posts/secondpost.md
I set layout tolayouts/post.liquid
, then the output is NOT correct anymoreExpected behavior
The arguments should be passed 2 times the same and the output would be
instead of
Environment:
Additional context
If I add one more page using the liquid template it outputs something like this
The text was updated successfully, but these errors were encountered: