Ticket #1108: defaultFilters.diff

File defaultFilters.diff, 804 bytes (added by scum, 19 years ago)

defaultFilters diff that adds an in filter {{ifValue|in:myList}}

  • core/template/defaultfilters.py

     
    226226    except IndexError:
    227227        return ''
    228228
     229def in_(value, arg):
     230    """
     231    Returns True if `a` is found in list `b`. False if not found. 
     232    {{ a|in:b }}
     233    or
     234    {{ isThisValue|in:thisListOfValues }}
     235    """
     236    return value in arg
     237
    229238def join(value, arg):
    230239    "Joins a list with a string, like Python's ``str.join(list)``"
    231240    try:
     
    443452register.filter(fix_ampersands)
    444453register.filter(floatformat)
    445454register.filter(get_digit)
     455register.filter('in', in_)
    446456register.filter(join)
    447457register.filter(length)
    448458register.filter(length_is)
Back to Top