Permalink
Browse files

magic-removal: Fixed #1304 -- template.resolve_variable() now resolve…

…s integers, as in trunk. When did this get removed, I wonder?

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2222 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 124944e commit 77816bc850bb108d4b800022066a993f139d7c47 @adrianholovaty adrianholovaty committed Feb 2, 2006
Showing with 7 additions and 1 deletion.
  1. +7 −1 django/template/__init__.py
View
8 django/template/__init__.py
@@ -605,7 +605,13 @@ def resolve_variable(path, context):
(The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.')
"""
- if path[0] in ('"', "'") and path[0] == path[-1]:
+ if path[0] in '0123456789':
+ number_type = '.' in path and float or int
+ try:
+ current = number_type(path)
+ except ValueError:
+ current = ''
+ elif path[0] in ('"', "'") and path[0] == path[-1]:
current = path[1:-1]
else:
current = context

0 comments on commit 77816bc

Please sign in to comment.