On Aug 13, 2006, at 6:01 PM, SmileyChris wrote:

>
>
> Adrian Holovaty wrote:
>> On 7/31/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
>>> I would actually be okay writing the function in the view code,  
>>> if we
>>> had a map filter.
>>>
>>> {{ s.teachers|map:list_func|join:";" }}
>>>
>>> Then add the following to the context:
>>>
>>> "list_func": lambda(x): x.userinfo.informal_name()
>>>
>>> How hard would that be to implement, and is it potentially useful
>>> enough that it'd be worth it?
>>
>> One problem with that is that template filters can't be objects at  
>> the
>> moment -- they can only be strings.
>
> I like Tod's solution and I don't see the problem, maybe I'm missing
> something:
>
> We have a function being passed to context -- I don't see why that
> would be a problem since the context can contain objects.
>
> And we have a template filter named |map which takes a list, does
> something to it, and returns a list -- just like |slice does now.

The problem Adrian mentions is that slice takes a string (such as  
"1:7" or ":2"), whereas map would have to take an argument and look  
it up in the context. I'm not even sure if the context is available  
when the filter argument would have to be resolved.

Todd

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to