我正在为我的 Web 应用程序使用 django,但我在 HTML5 中遇到冗长的长标签。
有没有办法像其他语言那样对冗长的标签进行换行?
例如,在 python 中,它会更容易阅读
if a and b and \
c and d and e and f:
print 'line breaking makes me easy to read'
比
if a and b and c and d and e and f ...:
print 'verbose expression without line break makes me hard to read'
那么有什么办法可以在 HTML5 标签中打断长行吗?
例如,做 like 的语法是否正确
<script
data-main="{% static 'my-long-application-name/app.js' %}"
src="{% static 'my-long-application-name/require.js' %}">
</script>
代替
<script data-main="{% static 'my-long-application-name/app.js' %}" src={% static 'my-long-application-name/require.js' %}></script>
处理这些冗长标签的最通用方法是什么?
最佳答案
你可以自由地将冗长的标签分成几行,你知道的,Humans should not have to grok XML ;)
您也可以申请django-htmlmin (HTML minifier)根据要求自动转换:
<script
data-main="{% static 'my-long-application-name/app.js' %}"
src="{% static 'my-long-application-name/require.js' %}">
</script>
收件人:
<script data-main="{% static 'my-long-application-name/app.js' %}" src={% static 'my-long-application-name/require.js' %}></script>
关于django - 如何处理 HTML5 中的长脚本标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30389211/