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
Jinja2 fails to render template with more than 98 if/elif statements #759
Comments
This happens because Either way, I would recommend you to refactor your code to not have that many elifs - that sounds rather awful to have in the first place (but at least it seems to be generated code, so maybe not that bad) |
This avoids deep nesting in case of many `{% elif .. %}` blocks (which would fail during execution) and also deep recursion (which may fail during compilation) fixes pallets#759
This avoids deep nesting in case of many `{% elif .. %}` blocks (which would fail during execution) and also deep recursion (which may fail during compilation) fixes pallets#759
This avoids deep nesting in case of many `{% elif .. %}` blocks (which would fail during execution) and also deep recursion (which may fail during compilation) fixes pallets#759
I might have a fix for it - see the referenced PR. However, your Jinja version is ancient. This fix would go into 2.9.5 |
The thing is that I've found this bug using salt configuration management (that uses jinja templating for the states), not writing a python program directly. But of course, a state can be splitted in several files. Thanks @ThiefMaster |
Expected Behavior
No errors on rendering a template.
Actual Behavior
Having the following jinja template (
this.jinja2
) with 99if/elif
statements lines; when the template is rendered it shows the following error:On the other hand, if one of the
elif
statements line is removed (keeping 98elif
) the template is rendered correctly without any error.It seems that there is a hard limit on the number of
if/elif
statements.Template Code
this.jinja2
this.py
Full Traceback
Your Environment
The text was updated successfully, but these errors were encountered: