Flask returns 变量作为带引号的文本而不是 html 元素

Flask returns variable as text with quotes instead as html element

我正在尝试向 jinga 模板插入一个 html 文本,该文本将作为 python 脚本中的变量提交

Python:

@app.route('/faq', defaults={'faq_id': "keine_id"})
@app.route('/faq/<string:faq_id>')
def faq(faq_id):
    return render_template('faq.html', beschreibung=f"<p>{data['beschreibung']}</p>")

HTML:

    <div class="col-12 col-lg-5">
        <div class="single_product_desc">
            <div class="product-meta-data">
                <p class="product-price">{{titel}}</p>
            </div>
            {{ beschreibung }}
        </div>
    </div>

如果我访问该网页,该网页会将我的变量加载为文本而不是 html 代码,相反,我的文本周围只有引号,段落标签会被忽略:

有人知道如何解决这个问题吗?

此致!

你应该使用 jinja2 过滤器 "safe" 来抑制自动转义。

{{ beschreibung | safe }}