#5567: Last and nth template filters
----------------------+-----------------------------------------------------
   Reporter:  ChrisH  |                Owner:  nobody         
     Status:  new     |            Component:  Template system
    Version:  SVN     |           Resolution:                 
   Keywords:          |                Stage:  Unreviewed     
  Has_patch:  1       |           Needs_docs:  0              
Needs_tests:  0       |   Needs_better_patch:  0              
----------------------+-----------------------------------------------------
Changes (by ubernostrum):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Old description:

> Hi,
>
> It seemed like an oversight that there wasn't a "last" template filter
> similar to the "first" filter. I wrote it up, along with tests, and added
> in an nth filter that takes an arg and accessing that index of the value.
>
> >>> last([0, 1, 2, 3, 4])
> 4
> >>> last(u'Hello')
> u'o'
> >>> nth(['a', 'b', 'c', 'd'], 1)
> 'b'
> >>> nth(u'abcd', 1)
> u'b'

New description:

 Hi,

 It seemed like an oversight that there wasn't a "last" template filter
 similar to the "first" filter. I wrote it up, along with tests, and added
 in an nth filter that takes an arg and accessing that index of the value.

 {{{
 >>> last([0, 1, 2, 3, 4])
 4
 >>> last(u'Hello')
 u'o'
 >>> nth(['a', 'b', 'c', 'd'], 1)
 'b'
 >>> nth(u'abcd', 1)
 u'b'
 }}}

Comment:

 (cleaning up formatting in description)

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5567#comment:1>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to