Unable to reassign include arguments locally within the include file itself
See original GitHub issueRelated 11ty issue: https://github.com/11ty/eleventy/issues/2000
Steps to reproduce:
- Create an include that accepts one argument.
- Reassign the argument locally within the include.
- Render the argument.
- Invoke the include and specify a value for the argument.
- Observe that the value does not get overridden.
Example:
parent.html
{% include child.html color: "red" %}
child.html
{% assign color = "green" %}{{ color }}
Expected behavior: the output is green
.
Observed behavior: the output is red
.
If it’s okay, I’d like to take a crack at fixing this (if you think it’s realistic for a first-time contributor). I have a failing test locally to confirm, but I’ll need to figure out where in the code it’s breaking.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (10 by maintainers)
Top Results From Across the Web
c - __FILE__ macro shows full path - Stack Overflow
Example: So for my Jenkins builds I will add -ffile-prefix-map=${WORKSPACE}/=/ , and another to remove the local dev package install prefix.
Read more >Packer.nvim - GitHub
Uses native packages, supports Luarocks dependencies, written in Lua, ... required if you have packer configured as `opt` vim.cmd [[packadd packer.nvim]] ...
Read more >Troubleshooting Windows Subsystem for Linux | Microsoft Learn
File a new issue. If you have found a problem with WSL and there does not appear to be an existing issue, you...
Read more >Best practices for writing Dockerfiles - Docker Documentation
Best practices for writing Dockerfiles. This document covers recommended best practices and methods for building efficient images.
Read more >Configuration and credential file settings - AWS Documentation
The AWS CLI stores sensitive credential information that you specify with aws configure in a local file named credentials , in a folder...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@AleksandrHovhannisyan I’m pretty sure 11ty v1 (beta) supports the
render
tag as well (although it’s been a while since I’ve played with that).Although I do see that https://github.com/11ty/eleventy/blob/19b4884e83e420a3b42f334aa922140f9cb18353/package.json#L107 is pinned to a very specific version of liquidjs, so we might need to tweak that line from the 11ty side (or else you can try manually installing the latest liquidjs locally and then try setting your own custom library instance.
UPDATE: Filed https://github.com/11ty/eleventy/issues/2059 from the 11ty side to bump liquidjs version back to latest.
After digging into Liquid and LiquidJS (I wrote this part long time ago and it takes me quite a while to figure it out, sorry for this), I find that:
include
andlayout
are legacy tags which does not provide Context separation. In both Shopify/Liquid and LiquidJS,{% assgin %}
in{%include%}
files assigns to its parent template, thus will not hide include arguments. So it’s by design and that’s why{%include%}
tag is deprecated.render
enforces Context separation by creating a newContext
when render partials, but it has a bug resulting in{% assign %}
inside{%render%}
also not hiding render arguments. It’s definitely a bug and not consistent with Shopify/Liquid, I updated @AleksandrHovhannisyan 's PR and fixed this bug on v9.28.4, check it out!layout
is implemented just likeinclude
and still not works for now, I’ll consider provide a substitution forlayout
too if someone actually needs that. Feel free to open a feature request issue for it!