From 77816bc850bb108d4b800022066a993f139d7c47 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 2 Feb 2006 04:43:37 +0000 Subject: [PATCH] magic-removal: Fixed #1304 -- template.resolve_variable() now resolves 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 --- django/template/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django/template/__init__.py b/django/template/__init__.py index 4f06f34e6b..d18bc3758c 100644 --- a/django/template/__init__.py +++ b/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