>> Hope this helps,
>>
>> -tim
>>
>> [1]
>> http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters
> 
> I have two questions.
> 
> 1) I cannot find where must I write the register of the filter

Details on creating your own filters are at the 
writing-custom-template-filters link I gave above.  There's some 
additional information above that particular link as well if 
you've never created a template tag/filter before.  It's 
remarkably easy...just don't forget to load the tag/filter 
library in your template.

> 2) I have a structure like this:
> (caption1, caption2, caption3, caption4)
> (a,b,c,d)
> 
> I want to print it like:
> <table>
> <tr><td>Caption1</td><td>A</td></tr>
> <tr><td>Caption2</td><td>B</td></tr>
> <tr><td>Caption3</td><td>C</td></tr>
> <tr><td>Caption4</td><td>D</td></tr>
> 
> How can I do that? It seems a bit different than your, because you don't have 
> captions...

well, I did what was requested...I'll have to check my DWIM 
functionality. ;-)

If you want to just combine them, you can use python's zip() command:

   captions = ["Cap1", "Cap2", "Cap3"]
   data = ['A', 'B', 'C', 'D']
   pairs = zip(captions, data)
   # pass "pairs" to your template

then in your template you can use

   {% for caption, datum in pairs %}
    <tr>
     <td>{{ caption }}</td>
     <td>{{ datum }}</td>
    </tr>
   {% endfor %}

or, if you're not using trunk you may have to use a single 
variable like

   {% for pair in pairs %}
    <tr>
     <td>{{ pair.0 }}</td>
     <td>{{ pair.1 }}</td>
    </tr>
   {% endfor %}

While it would be possible to make a "zip" tag that would do this 
for you, IMHO, it really belongs in the view as it asserts an 
association between two data-sets (and thus is not presentational 
which would be a criterion for template tags in my book).

-tim






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to