Ticket #5567: filter-last.diff

File filter-last.diff, 886 bytes (added by Aaron C. de Bruyn, 17 years ago)
  • django/template/defaultfilters.py

     
    433433        return u''
    434434first.is_safe = True
    435435
     436
     437def last(value):
     438    "Returns the last item in a list"
     439    try:
     440        return value[-1]
     441    except IndexError:
     442        return u''
     443last.is_safe = True
     444
     445
    436446def join(value, arg):
    437447    """Joins a list with a string, like Python's ``str.join(list)``."""
    438448    try:
  • docs/templates.txt

     
    14031403
    14041404Joins a list with a string, like Python's ``str.join(list)``.
    14051405
     1406last
     1407~~~~
     1408
     1409Returns the last item in a list.
     1410
    14061411length
    14071412~~~~~~
    14081413
Back to Top