Opened 17 years ago

Last modified 13 years ago

#5567 closed

Last and nth template filters — at Version 1

Reported by: Chris H. Owned by: nobody
Component: Template system Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by James Bennett)

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'

Change History (2)

by Chris H., 17 years ago

Attachment: last_and_nth_filters.diff added

comment:1 by James Bennett, 17 years ago

Description: modified (diff)

(cleaning up formatting in description)

Note: See TracTickets for help on using tickets.
Back to Top