On Monday 03 June 2013, Russell Keith-Magee wrote:
> Alternatively, add new sub tags to {% for %}:
> 
> {% for bee in my_bonnet.bees %}
> {% pre %}
> <ul class='bee list'>
> {% body %}
>     <li>{{ bee }}<li>
> {% post %}
> </ul>
> {% empty %}
> <span>No bees in your bonnet.</span>
> {% endfor %}
> 
> but that's starting to get verbose, and leaves ambiguous what to do with
> content appearing between the opening {% for %} and the {% pre %}
> 
It's also sort of available already:

{% for bee in my_bonnet.bees %}

 {% if forloop.first %}
    <ul class='bee list'>
 {% endif %}

     <li>{{ bee }}<li>

 {% if forloop.last %}
   </ul>
 {% endif %}

{% empty %}
 <span>No bees in your bonnet.</span>
{% endfor %}

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 django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
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