title: Jinja2 for loop with conditions
body: <p>I have a data structure similar to</p>
  <pre><code>data = {{'value': 1, 'state': False},
          {'value': 2, 'state': True}}
  </code></pre>
  <p>Where the state and value will change based on outside conditions.</p>
  <p>I would like to use a Jinja2 <code>for-else</code> loop with conditions, like</p>
  <pre><code>{% for item in data where item.state == True %}
     {{ item.value }}
  {% else %}
     no true items
  {% endfor %}
  </code></pre>
  <p>I use the data structure in multiple places, and sometimes it all needs to be displayed. I'd like to only keep one copy of the structure, and have the Jinja2 template take care of either displaying the items with <code>state==True</code> or a message that there aren't any items, rather than having to pre-process it in Python before giving it to the template, or splitting the structure into multiple pieces.</p>
  <p>This is running on Google App Engine with Python 2.7 and Jinja2 2.6, and the data structure is backed by memcache.</p>