Changeset 3112
- Timestamp:
- 06/07/06 23:29:10 (2 years ago)
- Files:
-
- django/trunk/django/template/defaulttags.py (modified) (1 diff)
- django/trunk/django/template/__init__.py (modified) (7 diffs)
- django/trunk/tests/othertests/templates.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/template/defaulttags.py
r3108 r3112 503 503 {% endifnotequal %} 504 504 """ 505 bits = token.contents.split()505 bits = list(token.split_contents()) 506 506 if len(bits) != 3: 507 507 raise TemplateSyntaxError, "%r takes two arguments" % bits[0] django/trunk/django/template/__init__.py
r3098 r3112 57 57 import re 58 58 from inspect import getargspec 59 from django.utils.functional import curry60 59 from django.conf import settings 61 60 from django.template.context import Context, RequestContext, ContextPopException 61 from django.utils.functional import curry 62 from django.utils.text import smart_split 62 63 63 64 __all__ = ('Template', 'Context', 'RequestContext', 'compile_string') … … 164 165 165 166 def __str__(self): 166 return '<%s token: "%s...">' % ( 167 {TOKEN_TEXT: 'Text', TOKEN_VAR: 'Var', TOKEN_BLOCK: 'Block'}[self.token_type], 168 self.contents[:20].replace('\n', '') 169 ) 170 171 def __repr__(self): 172 return '<%s token: "%s">' % ( 173 {TOKEN_TEXT: 'Text', TOKEN_VAR: 'Var', TOKEN_BLOCK: 'Block'}[self.token_type], 174 self.contents[:].replace('\n', '') 175 ) 167 return '<%s token: "%s...">' % \ 168 ({TOKEN_TEXT: 'Text', TOKEN_VAR: 'Var', TOKEN_BLOCK: 'Block'}[self.token_type], 169 self.contents[:20].replace('\n', '')) 170 171 def split_contents(self): 172 return smart_split(self.contents) 176 173 177 174 class Lexer(object): … … 368 365 e.source = token.source 369 366 370 371 367 def lexer_factory(*args, **kwargs): 372 368 if settings.TEMPLATE_DEBUG: … … 380 376 else: 381 377 return Parser(*args, **kwargs) 382 383 378 384 379 class TokenParser: … … 565 560 provided = list(provided) 566 561 plen = len(provided) 567 (args, varargs, varkw, defaults)= getargspec(func)562 args, varargs, varkw, defaults = getargspec(func) 568 563 # First argument is filter input. 569 564 args.pop(0) … … 821 816 822 817 def simple_tag(self,func): 823 (params, xx, xxx, defaults)= getargspec(func)818 params, xx, xxx, defaults = getargspec(func) 824 819 825 820 class SimpleNode(Node): … … 838 833 def inclusion_tag(self, file_name, context_class=Context, takes_context=False): 839 834 def dec(func): 840 (params, xx, xxx, defaults)= getargspec(func)835 params, xx, xxx, defaults = getargspec(func) 841 836 if takes_context: 842 837 if params[0] == 'context': django/trunk/tests/othertests/templates.py
r3108 r3112 307 307 'ifequal09': ('{% ifequal a "test" %}yes{% else %}no{% endifequal %}', {}, "no"), 308 308 'ifequal10': ('{% ifequal a b %}yes{% else %}no{% endifequal %}', {}, "yes"), 309 310 # SMART SPLITTING 311 'ifequal-split01': ('{% ifequal a "test man" %}yes{% else %}no{% endifequal %}', {}, "no"), 312 'ifequal-split02': ('{% ifequal a "test man" %}yes{% else %}no{% endifequal %}', {'a': 'foo'}, "no"), 313 'ifequal-split03': ('{% ifequal a "test man" %}yes{% else %}no{% endifequal %}', {'a': 'test man'}, "yes"), 314 'ifequal-split04': ("{% ifequal a 'test man' %}yes{% else %}no{% endifequal %}", {'a': 'test man'}, "yes"), 315 'ifequal-split05': ("{% ifequal a 'i \"love\" you' %}yes{% else %}no{% endifequal %}", {'a': ''}, "no"), 316 'ifequal-split06': ("{% ifequal a 'i \"love\" you' %}yes{% else %}no{% endifequal %}", {'a': 'i "love" you'}, "yes"), 317 'ifequal-split07': ("{% ifequal a 'i \"love\" you' %}yes{% else %}no{% endifequal %}", {'a': 'i love you'}, "no"), 318 'ifequal-split08': (r"{% ifequal a 'I\'m happy' %}yes{% else %}no{% endifequal %}", {'a': "I'm happy"}, "yes"), 319 'ifequal-split09': (r"{% ifequal a 'slash\man' %}yes{% else %}no{% endifequal %}", {'a': r"slash\man"}, "yes"), 320 'ifequal-split10': (r"{% ifequal a 'slash\man' %}yes{% else %}no{% endifequal %}", {'a': r"slashman"}, "no"), 309 321 310 322 ### IFNOTEQUAL TAG ########################################################
