Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add testcases for nested regroup and dictsort

  • Loading branch information...
commit bef11675b5e2d86020609591641ad6c433d432e2 1 parent 9d3da50
@garazdawi garazdawi authored
Showing with 26 additions and 1 deletion.
  1. +26 −1 tests/src/erlydtl_unittests.erl
View
27 tests/src/erlydtl_unittests.erl
@@ -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>">>},
Please sign in to comment.
Something went wrong with that request. Please try again.