tera icon indicating copy to clipboard operation
tera copied to clipboard

Support filters in object for loop

Open Azorlogh opened this issue 1 year ago • 2 comments

While this syntax is currently supported:

for element in array | myfilter

This one is unfortunately not:

for key, value in object | myfilter

Azorlogh avatar Nov 22 '24 12:11 Azorlogh

I also think this is a problem. But, I have a different view. It would be better to introduce such a syntax element (as is possible in Jinja2):

{% for k, v in my_map if k | length >= 10 and v is not null %}

That is, supporting the ternary operator in for would solve a lot of problems.

azemlya avatar Nov 22 '24 13:11 azemlya

I'm not sure about ternaries in for. Tera has continue/break so I feel like it wouldn't be needed, you can just have a if in your loop

Keats avatar Nov 25 '24 09:11 Keats