Skip to content

Commit

Permalink
Small improvement to django.template.resolve_variable -- isdigit() in…
Browse files Browse the repository at this point in the history
…stead of 0123456789

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3098 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jun 7, 2006
1 parent 3db34ce commit b78b1b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions django/template/__init__.py
Expand Up @@ -544,7 +544,7 @@ def __init__(self, token, parser):
upto = match.end() upto = match.end()
if upto != len(token): if upto != len(token):
raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:] raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:]
self.var , self.filters = var, filters self.var, self.filters = var, filters


def resolve(self, context): def resolve(self, context):
try: try:
Expand Down Expand Up @@ -614,7 +614,7 @@ def resolve_variable(path, context):
(The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.') (The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.')
""" """
if path[0] in '0123456789': if path[0].isdigit():
number_type = '.' in path and float or int number_type = '.' in path and float or int
try: try:
current = number_type(path) current = number_type(path)
Expand Down Expand Up @@ -655,7 +655,7 @@ def resolve_variable(path, context):
if getattr(e, 'silent_variable_failure', False): if getattr(e, 'silent_variable_failure', False):
current = settings.TEMPLATE_STRING_IF_INVALID current = settings.TEMPLATE_STRING_IF_INVALID
else: else:
raise raise
del bits[0] del bits[0]
return current return current


Expand Down

0 comments on commit b78b1b9

Please sign in to comment.