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

Allow referring to root context with . #24

Open
rossmacarthur opened this issue Feb 23, 2024 · 2 comments
Open

Allow referring to root context with . #24

rossmacarthur opened this issue Feb 23, 2024 · 2 comments
Labels
feature New feature or request

Comments

@rossmacarthur
Copy link
Owner

This could be useful if the root context is not a map, see #22.

There are some questions here though because the root context is not a single map but rather multiple scopes containing values. This would require copying the entire context which could potentially be expensive.

@rossmacarthur rossmacarthur added the feature New feature or request label Feb 23, 2024
@qq253498229
Copy link

qq253498229 commented Aug 23, 2024

Has this feature been released? @rossmacarthur
How should I use the variables passed from the parent template?

parent:

{% include "text-format" with node.children %}

child:

{% for child in . %}
{% if child.category.type | eq: "Text" %}
{{ child.category.text }}
{% endif %}
{% endfor %}

error:

invalid syntax

  --> text-format:1:17
   |
 1 | {% for child in . %}
   |                 ^--
   |
   = reason: expected expression, found member access operator

@rossmacarthur
Copy link
Owner Author

rossmacarthur commented Aug 24, 2024

It hasn't been implemented. You will have to pass node to the sub template right now.

{% include "text-format" with node %}
{% for child in children %}
{% if child.category.type | eq: "Text" %}
{{ child.category.text }}
{% endif %}
{% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants