Changes between Initial Version and Version 1 of BasicComparisonFilters


Ignore:
Timestamp:
Oct 23, 2006, 2:16:50 AM (18 years ago)
Author:
Le Roux
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BasicComparisonFilters

    v1 v1  
     1{{{
     2from django.template import Library
     3
     4def gt(value, arg):
     5    "Returns a boolean of whether the value is greater than the
     6argument"
     7    return value > int(arg)
     8
     9def lt(value, arg):
     10    "Returns a boolean of whether the value is less than the argument"
     11    return value < int(arg)
     12
     13def gte(value, arg):
     14    "Returns a boolean of whether the value is greater than or equal to
     15the argument"
     16    return value >= int(arg)
     17
     18def lte(value, arg):
     19    "Returns a boolean of whether the value is less than or equal to
     20the argument"
     21    return value <= int(arg)
     22
     23def length_gt(value, arg):
     24    "Returns a boolean of whether the value's length is greater than
     25the argument"
     26    return len(value) > int(arg)
     27
     28def length_lt(value, arg):
     29    "Returns a boolean of whether the value's length is less than the
     30argument"
     31    return len(value) < int(arg)
     32
     33def length_gte(value, arg):
     34    "Returns a boolean of whether the value's length is greater than or
     35equal to the argument"
     36    return len(value) >= int(arg)
     37
     38def length_lte(value, arg):
     39    "Returns a boolean of whether the value's length is less than or
     40equal to the argument"
     41    return len(value) <= int(arg)
     42
     43register = Library()
     44register.filter('gt', gt)
     45register.filter('lt', lt)
     46register.filter('gte', gte)
     47register.filter('lte', lte)
     48register.filter('length_gt', length_gt)
     49register.filter('length_lt', length_lt)
     50register.filter('length_gte', length_gte)
     51register.filter('length_lte', length_lte)
     52}}}
Back to Top