Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}' in html

i’m trying to make an if into my code html with flask:

 {% if  {{ role }}  = 1  %}
            <div id="cabecera">
                <header class="py-3 mb-4 border-bottom">
                    <div class="container d-flex flex-wrap justify-content-center">
                    <a href="/home" class="d-flex align-items-center mb-3 mb-lg-0 me-lg-auto text-dark text-decoration-none">

i send {{ role }} from the login but when i execute the code, it say this:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

i’m trying to control the view with permissions, if role is 1 show a div but if is other number, show a diferent div.

>Solution :

Try this:

{% if role == 1 %}
    <div id="cabecera">
        <header class="py-3 mb-4 border-bottom">
            <div class="container d-flex flex-wrap justify-content-center">
                <a href="/home" class="d-flex align-items-center mb-3 mb-lg-0 me-lg-auto text-dark text-decoration-none">
(...)
{% endif %}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading