Changeset 6571
- Timestamp:
- 10/20/07 10:01:31 (1 year ago)
- Files:
-
- django/trunk/django/template/defaulttags.py (modified) (1 diff)
- django/trunk/docs/templates.txt (modified) (1 diff)
- django/trunk/tests/regressiontests/templates/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/template/defaulttags.py
r6539 r6571 518 518 519 519 but obviously much cleaner! 520 """ 521 bits = token.contents.split()[1:] 520 521 You can also use a literal string as a fallback value in case all 522 passed variables are False:: 523 524 {% firstof var1 var2 var3 "fallback value" %} 525 526 """ 527 bits = token.split_contents()[1:] 522 528 if len(bits) < 1: 523 529 raise TemplateSyntaxError, "'firstof' statement requires at least one argument" django/trunk/docs/templates.txt
r6562 r6571 476 476 {{ var3 }} 477 477 {% endif %}{% endif %}{% endif %} 478 479 You can also use a literal string as a fallback value in case all 480 passed variables are False:: 481 482 {% firstof var1 var2 var3 "fallback value" %} 478 483 479 484 for django/trunk/tests/regressiontests/templates/tests.py
r6366 r6571 342 342 'firstof04': ('{% firstof a b c %}', {'a':0,'b':0,'c':3}, '3'), 343 343 'firstof05': ('{% firstof a b c %}', {'a':1,'b':2,'c':3}, '1'), 344 'firstof06': ('{% firstof %}', {}, template.TemplateSyntaxError), 344 'firstof06': ('{% firstof a b c %}', {'b':0,'c':3}, '3'), 345 'firstof07': ('{% firstof a b "c" %}', {'a':0}, 'c'), 346 'firstof08': ('{% firstof a b "c and d" %}', {'a':0,'b':0}, 'c and d'), 347 'firstof09': ('{% firstof %}', {}, template.TemplateSyntaxError), 345 348 346 349 ### FOR TAG ###############################################################
