What does this β€œ-” do in the jinja2 template engine?

I am learning jinja2 because the Google App Engine recommends it.

I found this example on Wikipedia: http://en.wikipedia.org/wiki/Jinja_%28template_engine%29

  {%- for item in item_list %}
    {{ item }}{% if not loop.last %},{% endif %}
  {%- endfor %}

What is the "-" in "{% - for"?

Also, where can I find jinja2 examples (better with the Google App Engine)?

Thank you so much!

+5
source share
1 answer

It suppresses the extra vertical spacing commonly used when you don't want an excessive distance between the elements you make.

If you put a minus sign (-) at the beginning or end of a block (for example a for a tag), a comment or variable expression that you can remove spaces after or before this block

: http://jinja.pocoo.org/docs/templates/#whitespace-control

+5

All Articles