Trimming blocks using whitespace control from jinja2 template
<p>I'm trying to print a single blank line surrounding the results of a jinja2 for loop, but I just can't get it to work. Can someone tell me what I am doing wrong?</p>

<pre><code>from jinja2 import Template, Environment

template = Template("""This is some text that should have a single blank line below it.

{% for i in range(10) -%}
line {{ i }}
{% endfor %}

This is some text that should have a single blank line above it.""")

template.environment = Environment(trim_blocks=True)

print(template.render())
</code></pre>

<p>This is the result I get:</p>

<pre><code>This is some text that should have a single blank line below it.

line 0
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9


This is some text that should have a single blank line above it.
</code></pre>

<p>However, I'm trying to configure it so that I don't get two blank lines above the final line, only one.</p>