[Python] flask learning ifelse statements - not working [closed]

Discussão em 'Python' iniciado por Stack, Outubro 2, 2024.

  1. Stack

    Stack Membro Participativo

    so I am well trained in python, but new to flask, which is why I am learning from books. I have encountered a problem, where I follow code from the book and adjust my index.html file for form rendering in the website. I use the following code:

    {% extends "base.html" %}
    {% import "bootstrap/wtf.html" as wtf %}

    {% block title %}flasky{% endblock %}

    {% block page_content %}
    <div class="page-header">

    <h1>Hello,{% if name %}{{name}}{% else %}stranger{% endif %}!</h1>

    </div>
    {{ wtf.quick_form(form) }}
    {% endblock %}


    but when I try to run it to see the result in the browser, I get the following error:

    <h1>Hello,{% if name %}{{name}}{% else %}stranger{% endif %}!</h1>
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    jinja2.exceptions.TemplateSyntaxError: Unexpected end of template. Jinja was looking for the following tags: 'endblock'. The innermost block that needs to be closed is 'block'


    I am honestly at a loss for words, as the structure of the line, should be in accordance with what I see from other sources detailing ifelse-statements in this case. Why can't I get this code to work ?

    Continue reading...

Compartilhe esta Página