Ticket #3022: resolve_numbers.patch

File resolve_numbers.patch, 715 bytes (added by Chris Beaven, 18 years ago)

With a regular expression

  • django/template/__init__.py

     
    604604    def __str__(self):
    605605        return self.token
    606606
     607re_number = re.compile('[+-]?(\d+|\d*\.\d+)$')
     608
    607609def resolve_variable(path, context):
    608610    """
    609611    Returns the resolved variable, which may contain attribute syntax, within
     
    624626
    625627    (The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.')
    626628    """
    627     if path[0].isdigit():
     629    if re_number.match(path[0]):
    628630        number_type = '.' in path and float or int
    629631        try:
    630632            current = number_type(path)
Back to Top