407 | 408 | 'cycle13': ("{% for i in test %}{% cycle 'a' 'b' %}{{ i }},{% endfor %}", {'test': range(5)}, 'a0,b1,a2,b3,a4,'), |
408 | 409 | 'cycle14': ("{% cycle one two as foo %}{% cycle foo %}", {'one': '1','two': '2'}, '12'), |
409 | 410 | 'cycle13': ("{% for i in test %}{% cycle aye bee %}{{ i }},{% endfor %}", {'test': range(5), 'aye': 'a', 'bee': 'b'}, 'a0,b1,a2,b3,a4,'), |
| 585 | |
| 586 | ## FILTER EXPRESSIONS AS ARGUMENTS ######################################## |
| 587 | 'ifequal-filter01': ('{% ifequal a|upper "A" %}x{% endifequal %}', {'a': 'a'}, 'x'), |
| 588 | 'ifequal-filter02': ('{% ifequal "A" a|upper %}x{% endifequal %}', {'a': 'a'}, 'x'), |
| 589 | 'ifequal-filter03': ('{% ifequal a|upper b|upper %}x{% endifequal %}', {'a': 'x', 'b': 'X'}, 'x'), |
| 590 | 'ifequal-filter04': ('{% ifequal x|slice:"1" "a" %}x{% endifequal %}', {'x': 'aaa'}, 'x'), |
| 591 | 'ifequal-filter05': ('{% ifequal x|slice:"1"|upper "A" %}x{% endifequal %}', {'x': 'aaa'}, 'x'), |
| 630 | 'include-with01': ('{% include "basic-syntax02" with foo as headline %}', {'foo': 'Included'}, "Included"), |
| 631 | 'include-with02': ('{% include "basic-syntax03" with foo as first, bar as second %}', {"foo" : 1, "bar" : 2}, "1 --- 2"), |
| 632 | 'recursive-include': ('{% for item in items %}{{ item.label }}{% if not item.children|length_is:0 %}{% with item.children as items %}({% include "recursive-include" %}){% endwith %}{% endif %}{% endfor %}', { |
| 633 | 'items': [ |
| 634 | {'label': 1, 'children': [ |
| 635 | {'label': 2, 'children': [ |
| 636 | {'label': 3, 'children': []}, |
| 637 | {'label': 4, 'children': []}, |
| 638 | ]}, |
| 639 | {'label': 5, 'children': [ |
| 640 | {'label': 6, 'children': [ |
| 641 | {'label': 7, 'children': [ |
| 642 | {'label': 8, 'children': []}, |
| 643 | ]}, |
| 644 | {'label': 9, 'children': []}, |
| 645 | ]}, |
| 646 | ]}, |
| 647 | ]}, |
| 648 | ], |
| 649 | }, '1(2(34)5(6(7(8)9)))'), |
| 832 | ### NEGATIVE NUMERIC LITERALS ############################################# |
| 833 | 'negative-numeric-literal01': ('{{ -1 }}', {}, '-1'), |
| 834 | 'negative-numeric-literal02': ('{{ -2.01 }}', {}, '-2.01'), |
| 835 | 'negative-numeric-literal03': ('{{ -0.1 }}', {}, '-0.1'), |
| 836 | 'negative-numeric-literal04': ('{% ifequal -1 -1 %}x{% endifequal %}', {}, 'x'), |
| 837 | 'negative-numeric-literal05': ('{{ foo|default:-1 }}', {'foo': None}, '-1'), |
| 863 | |
| 864 | 'regroup03': ('{% regroup data by created|date:"F Y" as grouped %}' + \ |
| 865 | '{% for group in grouped %}' + \ |
| 866 | '{{ group.grouper }}' + \ |
| 867 | '({% for item in group.list %}' + \ |
| 868 | '{{ item.created|date:"d" }}' + \ |
| 869 | '{% endfor %})' + \ |
| 870 | '{% endfor %}', |
| 871 | {'data': [ |
| 872 | {'created': datetime(2008, 1, 1)}, |
| 873 | {'created': datetime(2008, 2, 2)}, |
| 874 | {'created': datetime(2008, 3, 3)}, |
| 875 | {'created': datetime(2008, 4, 4)}, |
| 876 | ]}, 'January 2008(01)February 2008(02)March 2008(03)April 2008(04)'), |
| 913 | 'with03': ('{% with a as b, b as a %}{{ a }}{{ b }}{% endwith %}', {'a': 'A', 'b': 'B'}, 'BA'), |
| 914 | 'with04': ('{% with a as b , b as a %}{{ a }}{{ b }}{% endwith %}', {'a': 'A', 'b': 'B'}, 'BA'), |
| 915 | 'with05': ('{% with a as b, b as a, "," as s %}{{ a }}{{ s }}{{ b }}{% endwith %}', {'a': 'A', 'b': 'B'}, 'B,A'), |
| 916 | 'with06': ('{% with a as b, \',\' as s, b as a %}{{ a }}{{ s }}{{ b }}{% endwith %}', {'a': 'A', 'b': 'B'}, 'B,A'), |
863 | | |
| 920 | 'with-error03': ('{% with a as x, as y %}x{% endwith %}', {'a': 'A', 'b': 'B'}, template.TemplateSyntaxError), |
| 921 | 'with-error04': ('{% with a as x, b as %}x{% endwith %}', {'a': 'A', 'b': 'B'}, template.TemplateSyntaxError), |
| 922 | 'with-error05': ('{% with as x, b as y %}x{% endwith %}', {'a': 'A', 'b': 'B'}, template.TemplateSyntaxError), |
| 923 | 'with-error06': ('{% with a as x | b as y %}x{% endwith %}', {'a': 'A', 'b': 'B'}, template.TemplateSyntaxError), |
| 924 | 'with-error07': ('{% with a as x xxx b as y %}x{% endwith %}', {'a': 'A', 'b': 'B'}, template.TemplateSyntaxError), |
| 925 | 'with-error08': ('{% with a xx x, b xx y %}x{% endwith %}', {'a': 'A', 'b': 'B'}, template.TemplateSyntaxError), |
| 926 | |