Flask:虽然指定了标记,但遇到未知的标记endif

2024-03-28 20:18:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个需要登录的flask sqlalchemy webapp。 只有当用户登录时,“注销”按钮才应在页面上可见。 所有这些页面都扩展了layout.html文件,如下所示:

<!DOCTYPE html>
<html lang="en">



<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Login</title>

    <link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
    {% block head %} {% endblock %} 

</head>

<body>
{% block body %}
<style type="text/css">
  #footer {
    position : absolute;
    bottom : 0;
  }
</style>
{ % if session['logged_in'] %}

<div id="footer" style="width:300px;height:100px"><a href="   {{url_for('logout')}}" style="width:100%;background:#f1f1f1;">Logout</a></div>

{% endif %}

{% endblock %}


    <script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
    <script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>

</body>

</html>

我得到的错误是:

TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endblock'.

需要关闭的最里面的块是'block'。

尽管已指定endblock和if标记 请帮我修好这个


Tags: nameurlforstylehtmljsscriptstatic