-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
What's wrong with this Jinja template when using {% elif %} #1253
Comments
I was able to reproduce the issue as it is described. I did some research on this, however, wasn't able to find the cause. |
The use of |
UPDATE: Just traced through the code, trying to update the |
An initial guess it that setting a name that's passed in to the render context is not intended to be supported, and there's something going on with that in the runtime. So we need to identify the code that's handling that and then decide whether to change it or raise a better error. |
I have the following Jinja template:
However, when rendering this template via Flask I get the error message that
form_data
in line 3 of this code section is undefined (which is not the case, I double-checked that):Now when I remove the
elif
block from that code section above (i.e. lines 8-10) then the very same template does work again and line 3 does not lead to an error any more.I am calling this template like so:
I double-checked that
request.form
(and thusform_data
within the template) is notNone
. And as said, I don't make any changes to this call, I just remove those lines from the template and then it's working.So my question: Why does removing the
elif
block fix this issue, and why is this error raised in the first place? What's wrong with myif-elif-else-endif
block? Is this a bug or am I missing something?The text was updated successfully, but these errors were encountered: