我创建了以下模板,该模板提供 csv 格式的输出。
A;B;C
{% for a in as %}
{% for b in a.b %}{{ a.a }};{{ b.b }};{{ b.c }};{% endfor %}
{% endfor %}
但是输出没有新行。您知道如何在上面的模板中打印新行 (\n
) 吗?
最佳答案
只需在 ;{{ b.c }};
和 {% endfor %}
之间按 enter
A;B;C
{% for a in as %}
{% for b in a.b %}{{ a.a }};{{ b.b }};{{ b.c }};
{% endfor %}
{% endfor %}
关于symfony - Twig 如何打印\n 换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43276569/