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

get_context is not documented #128

Open
setop opened this issue Jun 12, 2024 · 0 comments
Open

get_context is not documented #128

setop opened this issue Jun 12, 2024 · 0 comments

Comments

@setop
Copy link

setop commented Jun 12, 2024

I have a yaml file with a hundred of entries.

I want to iterate these entries in the order.

It was not clear how to get the root element of data.

Then I found this line of code

env.globals["get_context"] = lambda: data

And now I can do that:

{% for k, v in get_context().items() %}
{# do whatever with key #}
{# do whatever with value #}
{% endfor %}

to iterate the entries.

and that:

{{get_context()|length}} entries

To get the number of entries.

which is great :)

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

No branches or pull requests

1 participant