Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#13078 closed (invalid)

'cycle' in 'for x in y' Interpretation Problem

Reported by: Henning Owned by: nobody
Component: HTTP handling Version: 1.1
Severity: Keywords: 'cycle' 'for x in y' 'nested'
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi there,

using a nested for x in y and a cylce i experienced some issues. My code looks similar to this:

{% for x,y in z %}
<!-- {% cycle 'cylce_white' 'cycle_grey' as rowcolors %} -->

<tr> 
	<td class="{{ rowcolors }}"> some table</td>
	<td class="{{ rowcolors }}"/> some more tables... </td>

	{% for a in y %}
        <tr>
            <td class="{{ rowcolors }}"> some INNER table</td>
	    <td class="{{ rowcolors }}"/> some INNER more tables... </td>
	</tr>
	{% endfor %}
</tr>
{% endfor %}

So what i want is the inner tables in the same css style like the outer ones - than cycle. I know i can solve this through css.

Question: If i do not comment out the cylce statement in the beginning: "cycle 'bla' 'bla2' as 'blax' " the cycled value (here 'bla' and 'bla2' are readable in the page. Is that right? Am i doing sth. wrong here?

Python 2.6 (OSX Snow-Leo), Django 1.1.1, FireFox

Change History (3)

comment:1 by Luke Plant, 15 years ago

Resolution: invalid
Status: newclosed

This doesn't seem to be a bug report - if you are looking for help with a Django feature please ask on the django-users google group.

comment:2 by Henning, 15 years ago

I'm not looking for help. Solved it as described above. Just wanted to let you guys know there is something strange happening with that cycle tag.

I can even reproduce the problem with only one 'for x in y'
The code of

{% cycle 'a' 'b' as chars %}

will end up in the for x in y as:

abababababa

Anyway.

comment:3 by Luke Plant, 15 years ago

I'm still completely unclear as to what bug you are describing. Are you saying that the cycle tag works even if it is in an HTML comment? That is how it is supposed to work - the HTML comment is a comment only to the web browser to ignore the code, and Django's template system is completely oblivious to HTML comments.

Or are you saying that the tag outputs its value (as well as binding a variable if you use 'as')? That is also how it is supposed to work, as documented - http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#cycle

Note: See TracTickets for help on using tickets.
Back to Top