On Wed, Jul 7, 2010 at 5:00 PM, thusjanthan <thusjant...@gmail.com> wrote:
> This is the desired behavior. Until the loop is done it cycles the
> given values you provided in your case 'a' 'b' and since the loop is
> running 3 times it cycles back to 'a' again.
>
> Cheers,
> Thusjanthan
>

Thats not precisely what he was asking, I'm sure the OP was expecting
a sequence like a,b,a,b,a,b , he wasn't expecting additional values to
be output when defining the cycle variable.

I don't think this is a bug, just (undocumented) feature. I'm pretty
sure it's working as intended. Remember the use case for this is using
it outside of a loop and mainting cycle state, so something like so:

<tr class="{% cycle "a" "b" as rowstyle %}">...</tr>
{% for row in rows %}
<tr class="{{ rowstyle }}">...</tr>
{% endfor %}
{% for row in other_rows %}
<tr class="{{ rowstyle }}">...</tr>
{% endfor %}

IE, it maintains the state of the cycle parameter between for loops.

Where I havent had the need to output an initial value, I've just
output it in a HTML comment. Simple and works.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to