最近在折腾python web的flask,碰到如下问题: 我有一个template叫index.html, 在body中包含如下内容
<p class="span9" id="news_loadding">
{% for item in news %}
<p class="weibo-text">{{ item['description'] }}</p>
{% endfor %}
</p>
现在变量{{ item['description'] }}的内容如下
现任<font color="RED">澳洲</font>总理吉拉德在澳大利亚工党领袖选举中输给陆克文。<br />
如何插入该变量的内容后,html正常解析这些标签??向大家求教
目前,{{ item['description'] }}的内容直接显示在页面上,也就是说<font..., <br/>
这些HTML标签原原本本的显示出来了,而没有解析。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
jinja 为了安全起见默认会对 html 进行转义,添加
safe
参数即可