Django

Code

Ticket #5567: filter-last.diff

File filter-last.diff, 0.9 kB (added by darkpixel, 10 months ago)
  • django/template/defaultfilters.py

    old new  
    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

    old new  
    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