【问题标题】:Whitespace Jinja2 into Template空白 Jinja2 到模板
【发布时间】: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


    【解决方案1】:

    您需要在模板中使用html。我请参考另一篇文章,它以某种方式描述了您的问题。

    How to format jinja tables

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-08
      • 1970-01-01
      • 2022-01-12
      • 2018-08-19
      • 1970-01-01
      • 2021-05-28
      • 2012-01-02
      • 2017-02-04
      相关资源
      最近更新 更多