我正在学习 jinja2,因为 Google App Engine 推荐它。
我在维基百科上找到了这个例子:http://en.wikipedia.org/wiki/Jinja_%28template_engine%29
{%- for item in item_list %}
{{ item }}{% if not loop.last %},{% endif %}
{%- endfor %}
“{%- for”中的“-”是什么意思?
另外,我在哪里可以找到 jinja2 示例(使用 Google App Engine 更好)?
非常感谢!
最佳答案
它抑制额外的垂直间距,通常在您不希望循环通过的元素之间的间距过大时使用。
If you put an minus sign (-) to the start or end of a block (for example a for tag), a comment or variable expression you can remove the whitespaces after or before that block
关于python - jinja2模板引擎中的这个 "-"是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11813422/