I'm working on a flask-sqlalchemy webapp that requires login. The logout button should be visible on the pages only if user is logged in. So all those pages extend layout.html file which looks like this:
<!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>
The error I'm getting is :
TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endblock'.
The innermost block that needs to be closed is 'block'.
Although the endblock and if tags have been specified Please help me fix this
Try removing the space between { and % in
{ % if session['logged_in'] %}
so that it becomes
{% if session['logged_in'] %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With