Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 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: UI/UX:

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

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by lukeplant

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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 Changed 4 years ago by Henning

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 Changed 4 years ago by lukeplant

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.