【发布时间】:2021-06-06 13:29:21
【问题描述】:
我想用 Jinja2 读取我的模板 HTML 中的字符串值,并尊重完全相同的空间。 但是,我没有找到完全有空格的解决方案。
我想在最后显示这个:
我的意见:
a = "Test_Compo\n Information : Return Composition with SRI
information of Portfolio\n\n Args :\n dict_data (dict
of str : list) : Default value\n see_url (boolean)
: Default value = False\n see_parameters (boolean)
: Default value = False\n\n"
context['name_class'] = [i for i in a.split('\n') if not i.strip() == '']
我的输出(在 Jinja2 中):
{% for info_method in Method_Info['name_class'] %}
<h4>{{info_method}}</h4>
{% endfilter %}
【问题讨论】:
标签: python html templates jinja2