Jinja2 template not rendering if-elif-else statement properly
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Jinja2 template not rendering if-elif-else statement properly:
You are testing if the values of the variables
error
andAlready
are present inRepoOutput[RepoName.index(repo)]
. If these variables don’t exist then an undefined object is used.Both of your
if
andelif
tests therefore are false; there is no undefined object in the value of RepoOutput[RepoName.index(repo)].I think you wanted to test if certain strings are in the value instead:
Other corrections I made:
{% elif ... %}
instead of{$ elif ... %}
.</tr>
tag out of theif
conditional structure, it needs to be there always.id
attributeNote that most likely you want to use a
class
attribute instead here, not anid
, the latter must have a value that must be unique across your HTML document.Personally, I’d set the class value here and reduce the duplication a little: