Issue
So in Flask I have this template:
{% extends "base.html" %}
{% block title %} Chatroom mit {{name}}{% endblock %}
{% block content %}
<div class="surline">
<div class="receiv_pic"><img src="static\images\{{prof_pic}}" class="rounded-circle"> </div> <div class="chat_name"><strong>{{name}}</strong></div>
</div>
<div class="chatter">
<div class="stylingtest">
{% for key in real_keys %}
<p>
{% if send in key %}
<div class="dropdown{% if rec in key %}rec{{leng_dict[key]}}{% elif send in key %}send{{leng_dict[key]}}{% endif %}">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
{{real_dict[key]}}
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<li><a class="dropdown-item" href="#"><form action="/{{user_id}}" method="POST"><input type="submit" name="delete" id="delete{{id_view[key]}}" value="Delete!"><input type="hidden" name="id_identifier" value="{{ id_view[key] }}" id="id{{id_view[key]}}"></form>
</a></li>
</ul>
</div>
{% elif rec in key %}
<div class="dropdownrec{{leng_dict[key]}}{% endif %}">
{{real_dict[key]}}
</div>
{% endif %}
</p>
{% endfor %}
</div>
</div>
<form method="POST" action="/{{user_id}}" class="message_input">
<input type="text" id="message" name="message" class="msg_input" autocomplete="off">
<input type="submit" value="submit" name="submit" class="submit_submit">
</form>
{% endblock %}
The error seems to occur in line 26: '{% endif %}'.
This is the error:
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.
real_dict is a dict with one item in it, and real_keys is the key. leng_dict is another working dict. send and rec are defined variables, they shouldn't cause an error.
I am confused, since I'm pretty sure endif is the innermost block, that needs to be closed. Also if I change it to endfor it still throws an error.
Any kind of help is appreciated, thank you very much
Solution
I believe this causes the error:
<div class="dropdownrec{{leng_dict[key]}}{% endif %}">
So, try removing {% endif %}
here.
Answered By - bichanna
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.