加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

flask开发中遇到 Encountered unknown tag 'endblock&#39

发布时间:2020-12-17 17:03:41 所属栏目:Python 来源:网络整理
导读:flask开发中遇错误,提示如下 jinja2.exceptions.TemplateSyntaxError?jinja2.exceptions.TemplateSyntaxError:?Encountered?unknown?tag?'endblock'.You?probably?made?a?nesting?mistake.?Jinja?is?expecting?this?tag,?but?currently?looking?for?'elif'?

flask开发中遇错误,提示如下

jinja2.exceptions.TemplateSyntaxError?jinja2.exceptions.TemplateSyntaxError:?Encountered?unknown?tag?'endblock'.
You?probably?made?a?nesting?mistake.?Jinja?is?expecting?this?tag,?but?currently?looking?for?'elif'?or?'else'?or?'endif'.
The?innermost?block?that?needs?to?be?closed?is?'if'.

这句话的意思是:遇到未知的‘板块’,这个板块是if

{%?extends?"base.html"?%}
{%?import?"bootstrap/wtf.html"?as?wtf?%}
{%?import?'_marcos.html'?as?macros?%}

{%?block?title?%}Flasky{%?endblock?%}

{%?block?page_content?%}
<div?class="page-header">
????<h1>Hello,?{%?if?current_user.is_authenticated?%}{{?current_user.username?}}{%?else?%}Stranger{%?endif?%}!</h1>
</div>
<div>
????{%?if?current_user.can(Permission.WRITE_ARTICLES)?%}
????{{?wtf.quick_form(form)?}}
????{%?endif?%}
</div>
{%?include?'_posts.html'?%}
????{%?if?pagination?%}
????????<div?class="pagination">
????????{{?macros.paginnation_widget(pagination,?".index")?}}
????????</div>
{%?endblock?%}

经过检查发现{% if pagination %} 少了一个结束,所以代码应该为:

{%?include?'_posts.html'?%}
????{%?if?pagination?%}
????????<div?class="pagination">
????????{{?macros.paginnation_widget(pagination,?".index")?}}
????????</div>
????{%?endif?%}
{%?endblock?%}


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读