Jinja模板的{%spaceless%}标签吗? [英] {% spaceless %} tag for Jinja templates?
本文介绍了Jinja模板的{%spaceless%}标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Django有一个有用的{% spaceless %}
标记,可从HTML去除多余的空白.
Django has a useful {% spaceless %}
tag that strips extra whitespace from HTML.
我的模板产生大量空白,而在所有地方添加{%-
和-%}
进行空白控制实在是太麻烦了.有没有人看到过类似Jinc的{% spaceless %}
或{% htmltidy %}
这样的过滤器,以便在开发时可以查看干净的HTML?
My templates are producing a lot of whitespace and it's too much of a pain to add the {%-
and -%}
everywhere to do whitespace control. Has anyone seen a filter like {% spaceless %}
for Jinja, or maybe {% htmltidy %}
, so that I could view clean HTML while developing?
推荐答案
有一个实现此效果的jinja2扩展,由jinja2开发人员编写
There is a jinja2 extension that achieves this effect, authored by the jinja2 developer
https://github.com/mitsuhiko/jinja2-htmlcompress
这篇关于Jinja模板的{%spaceless%}标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文