Replies: 2 comments 1 reply
-
The issue is that the expression won't be known until it runs. While in some simple cases you can probably derive the type of the result, but in many cases you can't. In particular the moment you apply a filter or anything like this you cannot know the result. It would be interesting what you are trying to accomplish. Maybe it can be accomplished in different ways. |
Beta Was this translation helpful? Give feedback.
-
We have some "recipes" defined in YAML that we parse with a mix of serde_yaml + Minijinja. There are sections like:
From the serde schema we know that e.g. I think for simple cases like this I can probably achieve it with some AST walking, and I agree, thinking about it a bit more it's really tough for everything that minijinja can do. |
Beta Was this translation helpful? Give feedback.
-
We are interested in being able to get the evaluation type of an expression, and were wondering if that is somehow possible.
E.g. with an expression like
{{ 5 if win else 3 }}
the eval type would be integer, etc.This could be useful for type-checking when we don't know which branch is being taken.
It would be nice if, in addition to
.undeclared_variables
the expression could have aneval_type(context)
function that computes the type of the evaluation for all branches.I also completely understand if that's out of scope for Minijinja :)
Beta Was this translation helpful? Give feedback.
All reactions