|
@@ -399,6 +399,13 @@ tests() ->
|
|
|
<<"{{ var1|default_if_none:\"foo\" }}">>, [], <<"foo">>},
|
|
|
{"|default_if_none:\"foo\" 2",
|
|
|
<<"{{ var1|default_if_none:\"foo\" }}">>, [{var1, "bar"}], <<"bar">>},
|
|
|
+ {"|dictsort 1",
|
|
|
+ <<"{{ var1|dictsort:\"foo\" }}">>,
|
|
|
+ [{var1,[[{foo,2}],[{foo,1}]]}], <<"{foo,1}{foo,2}">>},
|
|
|
+ {"|dictsort 2",
|
|
|
+ <<"{{ var1|dictsort:\"foo.bar\" }}">>,
|
|
|
+ [{var1,[[{foo,[{bar,2}]}],[{foo,[{bar,1}]}]]}],
|
|
|
+ <<"{foo,[{bar,1}]}{foo,[{bar,2}]}">>},
|
|
|
{"|divisibleby:\"3\"",
|
|
|
<<"{% if var1|divisibleby:\"3\" %}yay{% endif %}">>, [{var1, 21}], <<"yay">>},
|
|
|
{"|divisibleby:\"3\"",
|
|
@@ -946,7 +953,25 @@ tests() ->
|
|
|
[{first_name, "Condi"}, {gender, "Female"}],
|
|
|
[{first_name, "Bill"}, {gender, "Male"}]
|
|
|
]}],
|
|
|
- <<"Male\nGeorge\nFemale\nMargaret\nCondi\nMale\nBill\n">>}
|
|
|
+ <<"Male\nGeorge\nFemale\nMargaret\nCondi\nMale\nBill\n">>},
|
|
|
+ {"NestedOrdered", <<"{% regroup people by name.last as lastname_list %}{% for lastname in lastname_list %}{{ lastname.grouper }}\n{% for item in lastname.list %}{{ item.name.first }}\n{% endfor %}{% endfor %}{% endregroup %}">>,
|
|
|
+ [{people, [[{name, [{first,"George"},{last,"Costanza"}]}],
|
|
|
+ [{name, [{first,"Margaret"},{last,"Costanza"}]}],
|
|
|
+ [{name, [{first,"Bill"},{last,"Buffalo"}]}],
|
|
|
+ [{name, [{first,"Condi"},{last,"Buffalo"}]}]]}],
|
|
|
+ <<"Costanza\nGeorge\nMargaret\nBuffalo\nBill\nCondi\n">>},
|
|
|
+ {"NestedUnordered", <<"{% regroup people by name.last as lastname_list %}{% for lastname in lastname_list %}{{ lastname.grouper }}\n{% for item in lastname.list %}{{ item.name.first }}\n{% endfor %}{% endfor %}{% endregroup %}">>,
|
|
|
+ [{people, [[{name, [{first,"George"},{last,"Costanza"}]}],
|
|
|
+ [{name, [{first,"Bill"},{last,"Buffalo"}]}],
|
|
|
+ [{name, [{first,"Margaret"},{last,"Costanza"}]}],
|
|
|
+ [{name, [{first,"Condi"},{last,"Buffalo"}]}]]}],
|
|
|
+ <<"Costanza\nGeorge\nBuffalo\nBill\nCostanza\nMargaret\nBuffalo\nCondi\n">>},
|
|
|
+ {"Filter", <<"{% regroup people|dictsort:\"name.last\" by name.last as lastname_list %}{% for lastname in lastname_list %}{{ lastname.grouper }}\n{% for item in lastname.list %}{{ item.name.first }}\n{% endfor %}{% endfor %}{% endregroup %}">>,
|
|
|
+ [{people, [[{name, [{first,"George"},{last,"Costanza"}]}],
|
|
|
+ [{name, [{first,"Bill"},{last,"Buffalo"}]}],
|
|
|
+ [{name, [{first,"Margaret"},{last,"Costanza"}]}],
|
|
|
+ [{name, [{first,"Condi"},{last,"Buffalo"}]}]]}],
|
|
|
+ <<"Buffalo\nBill\nCondi\nCostanza\nGeorge\nMargaret\n">>}
|
|
|
]},
|
|
|
{"spaceless", [
|
|
|
{"Beginning", <<"{% spaceless %} <b>foo</b>{% endspaceless %}">>, [], <<"<b>foo</b>">>},
|