Hi,

On Monday 03 June 2013, Andre Terra wrote:
> Well, Russ, you asked for suggestions, so here's a couple half-hearted
> attempts.
> 

... and here's a couple of other ones, mostly inspired by those:

> {% with my_bonnet.bees as bees if my_bonnet.bees %}
> {% if my_bonnet.bees with my_bonnet.bees as bees %}

The only problem I see with these is the repetition -- we could just allow 
"as" on {% if %}:

{% if my_bonnet.bees as bees %}
     <ul class="bee list">
     {% for bee in bees %}
         <li>{{ bee }}</li>
     {% endfor %}
     </ul>
{% else %}
     <span>No bees!</span>
{% endif %}

Another (halfbaked) idea: Allow separating the "in" from the {% for %}. Let a 
{% for %} with no "in"  make a collection "current", and then its elements can 
be iterated over by, say, {% each %}:

{% for my_bonnet.bees %}
     <ul class="bee list">
     {% each bee %}
         <li>{{ bee }}</li>
     {% endeach %}
     </ul>
{% empty %}
     <span>No bees!</span>
{% endfor %}

The problem I see with this: it's perhaps a tad too implicit.

HTH,
        Shai.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to