有没有办法清理jinja2产生的html? [英] Is there a way to clean up the html that jinja2 produces?

查看:45
本文介绍了有没有办法清理jinja2产生的html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用jinja2来创建html,但是由于在jinja中为了生成html而进行了许多循环和其他操作,因此html看上去丑陋".(注意:这只是出于美学目的).有什么我们可以做的清理html吗? (除了清理我们的jinja2代码的明显做法外,这会使我们的模板对我们的工作人员有些不可读)

We are using jinja2 to create our html but, because of the many loops and other things we do in jinja to produce the html, the html 'looks' ugly....(note: this is just for aesthetics). Is there anything we can do to clean up the html? (Other than the obvious of cleaning up our jinja2 code, which would make our template somewhat unreadable to us staffers)

像美汤一样漂亮吗?

(是的,我知道这个问题是个很挑剔的问题……我里面的ocd说要清理它).

(Yes, I realize this question is a pretty nit-picky question...the ocd in me says to clean it up).

例如:

                              <table>

      <tbody>


                  <tr>
                    <td>

                     a column

                    </td>




                                <td>

                                    a value

                                </td>
                      </tr>
                     </tbody>
           </table>     

丑陋,是吗?

推荐答案

在标签中添加-":

{%- if 'this'=='this' -%}
    {{ blah }}
{%- endif -%}

这篇关于有没有办法清理jinja2产生的html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆