我想使用“ jinja2”为我的博客网站显示“ Flask”的评论和回复功能,因此我试图在评论部分中以示例的方式显示回复,或者请建议是否有人可以更好地管理评论和烧瓶回复:
{% for comments in comment_data %} #comments came from different table
<p>User:{{comments[1]}} </p> #for user email or name
<p>comment: {{comments[0]}}</p> #for comment content
{% for reply in reply_data %}
{%if comment[0]==reply[0]%} # check comments id from both table
# i need this portion because every comment can have separate reply
section and reply content
<p>User:{{reply[0]}} </p> #for user email or name
<p>comment: {{reply[1]}}</p> #for reply content
{% endif %}
{% endfor %}
{%endfor%}
答案 0 :(得分:0)
我找到了答案,如果我想在语句分隔符内使用jinja2 var,则不需要使用表达式分隔符: {%if评论[0] ==回复[0]%}