0

I have this template in a Flask app:

{% extends 'base.html' %}

{% block content %}
    <h1>{% block title %} Welcome to the Testbank {% endblock %}</h1>
    
        <table>
            <tr>
                <th>ID
                </th>
                <th>Content
                </th>
                <th>Level</th>
            </tr>
            {% for question in questions %}
            <tr>
                <td>  
                    {{question['qid']}}
                </td>
                <td>
                    {{question['content']}}
                </td>
                <td>{{question['level']}}</td>
            </tr>
            {% endfor %}
           
        </table>    
        
{% endblock %}

then it prints out <td>'<p> content</p>'</td> instead of <td><p> content</p></td>

Is there a way to turn the string tag into an html tag in python. In ruby, there is this syntax <td> {{question['qid']}} | to_html </td>

python_user
  • 5,375
  • 2
  • 13
  • 32
Dr Linh Chi Nguyen
  • 1,063
  • 1
  • 9
  • 17
  • 1
    `{{question['qid'] | safe}}` perhaps? https://jinja.palletsprojects.com/en/3.1.x/templates/#working-with-automatic-escaping – python_user Dec 24 '22 at 11:35

0 Answers0