Ticket #361: filter_math.patch

File filter_math.patch, 1.3 KB (added by till@…, 16 years ago)
  • template/defaultfilters.py

     
    593593    return int(value) + int(arg)
    594594add.is_safe = False
    595595
     596def mult(value, arg):
     597    "Multiplies the arg and the value"
     598    return int(value) * int(arg)
     599mult.is_safe = False
     600
     601def sub(value, arg):
     602    "Subtracts the arg from the value"
     603    return int(value) - int(arg)
     604sub.is_safe = False
     605
     606def div(value, arg):
     607    "Divides the value by the arg"
     608    return int(value) / int(arg)
     609div.is_safe = False
     610
    596611def get_digit(value, arg):
    597612    """
    598613    Given a whole number, returns the requested digit of it, where 1 is the
     
    804819register.filter(default_if_none)
    805820register.filter(dictsort)
    806821register.filter(dictsortreversed)
     822register.filter(div)
    807823register.filter(divisibleby)
    808824register.filter(escape)
    809825register.filter(escapejs)
     
    824840register.filter(ljust)
    825841register.filter(lower)
    826842register.filter(make_list)
     843register.filter(mult)
    827844register.filter(phone2numeric)
    828845register.filter(pluralize)
    829846register.filter(pprint)
     
    835852register.filter(slugify)
    836853register.filter(stringformat)
    837854register.filter(striptags)
     855register.filter(sub)
    838856register.filter(time)
    839857register.filter(timesince)
    840858register.filter(timeuntil)
Back to Top