title: If statement on for statement in Jinja2
body: <p>I have a website hosted in GAE and within my Jinja2 template I have an IF statement in a FOR statement.</p>
  
  <p>I have enabled my <strong>jinja2.ext.loopcontrols</strong> loop control using:</p>
  
  <pre><code>template_dir = os.path.dirname(__file__)
  ENV = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir),
                                         autoescape=True,
                                         extensions=['jinja2.ext.autoescape',
                                                     'jinja2.ext.loopcontrols'])
  </code></pre>
  
  <p>My template looks like this:</p>
  
  <pre><code>{% for i in data %}
    (% if i.date_posted is defined %)
      {{ i.date_posted.strftime('%d %b %Y') }}
    {% else %}
      No
    {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>I keep getting the error:</p>
  
  <blockquote>
    <p>TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor'. The innermost block that needs to be closed is 'for'.</p>
  </blockquote>