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