Changeset 1690
- Timestamp:
- 12/15/05 23:33:24 (3 years ago)
- Files:
-
- django/trunk/django/core/template/__init__.py (modified) (2 diffs)
- django/trunk/tests/othertests/templates.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/template/__init__.py
r1497 r1690 630 630 Returns the resolved variable, which may contain attribute syntax, within 631 631 the given context. The variable may be a hard-coded string (if it begins 632 and ends with single or double quote marks) .632 and ends with single or double quote marks), or an integer or float literal. 633 633 634 634 >>> c = {'article': {'section':'News'}} … … 646 646 (The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.') 647 647 """ 648 if path[0] in ('"', "'") and path[0] == path[-1]: 648 if path[0] in '0123456789': 649 number_type = '.' in path and float or int 650 try: 651 current = number_type(path) 652 except ValueError: 653 current = '' 654 elif path[0] in ('"', "'") and path[0] == path[-1]: 649 655 current = path[1:-1] 650 656 else: django/trunk/tests/othertests/templates.py
r1586 r1690 164 164 'ifequal09': ('{% ifequal a "test" %}yes{% else %}no{% endifequal %}', {}, "no"), 165 165 'ifequal10': ('{% ifequal a b %}yes{% else %}no{% endifequal %}', {}, "yes"), 166 167 # Integers 168 'ifequal11': ('{% ifequal a 1 %}yes{% else %}no{% endifequal %}', {}, "no"), 169 'ifequal12': ('{% ifequal a 1 %}yes{% else %}no{% endifequal %}', {"a": 1}, "yes"), 170 'ifequal13': ('{% ifequal a 1 %}yes{% else %}no{% endifequal %}', {"a": "1"}, "no"), 171 'ifequal14': ('{% ifequal a "1" %}yes{% else %}no{% endifequal %}', {"a": 1}, "no"), 172 'ifequal15': ('{% ifequal a "1" %}yes{% else %}no{% endifequal %}', {"a": "1"}, "yes"), 173 174 # Floats 175 'ifequal16': ('{% ifequal a 1.2 %}yes{% else %}no{% endifequal %}', {}, "no"), 176 'ifequal17': ('{% ifequal a 1.2 %}yes{% else %}no{% endifequal %}', {"a": 1.2}, "yes"), 177 'ifequal18': ('{% ifequal a 1.2 %}yes{% else %}no{% endifequal %}', {"a": "1.2"}, "no"), 178 'ifequal19': ('{% ifequal a "1.2" %}yes{% else %}no{% endifequal %}', {"a": 1.2}, "no"), 179 'ifequal20': ('{% ifequal a "1.2" %}yes{% else %}no{% endifequal %}', {"a": "1.2"}, "yes"), 166 180 167 181 ### IFNOTEQUAL TAG ########################################################
