On 3 Feb 2008, at 3:32 pm, Michael Hipp wrote:
>
> Malcolm Tredinnick wrote:
>>> Or is there some other way to get at my 'align' list?
>>
>> Look at the {% cycle %} template tag. It's designed for precisely
>> this
>> purpose.
>
> Thank you. But can someone show me how to make 'cycle' work?
>
> from django.template import Context, Template
> items = (0, 1, 2, 3, 4, 5)
> mycycle = ("one", "two", "three")
> t = Template("""
> {% for item in items %}
> {% cycle mycycle %}
> {% endfor %}
> """)
> t.render(Context({ "items": items, "mycycle": mycycle }))
Put in your template:
{% for item in items %}
<div class="{% cycle left,right %}>
Some text here
</div>
{% endfor %}
Then a left and right class in your CSS to do the aligning.
--
David Reynolds
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---