Skip to content
Browse files

Fix bug in new scope routine (#101)

When there was some text surrounding the sub scope,
it only kept the last piece.
Tests updated to catch this.
  • Loading branch information...
1 parent 4aa8787 commit c1eebb25f3da209bed163bc22619a6ff5c6c4055 @kaos kaos committed
Showing with 7 additions and 2 deletions.
  1. +1 −1 src/erlydtl_beam_compiler.erl
  2. +6 −1 tests/src/erlydtl_unittests.erl
View
2 src/erlydtl_beam_compiler.erl
@@ -674,7 +674,7 @@ body_ast(DjangoParseTree, TreeWalker) ->
AstInfoList),
{Ast, TreeWalker3} = end_scope(
- fun (AstScope) -> [?Q("begin _@AstScope end")] end,
+ fun ([ScopeVars|ScopeBody]) -> [?Q("begin _@ScopeVars, [_@ScopeBody] end")] end,
ScopeId, AstList, TreeWalker2),
{{erl_syntax:list(Ast), Info}, TreeWalker3}.
View
7 tests/src/erlydtl_unittests.erl
@@ -1180,7 +1180,12 @@ tests() ->
[{name, [{first,"Bill"},{last,"Buffalo"}]}],
[{name, [{first,"Margaret"},{last,"Costanza"}]}],
[{name, [{first,"Condi"},{last,"Buffalo"}]}]]}],
- <<"Buffalo\nBill\nCondi\nCostanza\nGeorge\nMargaret\n">>}
+ <<"Buffalo\nBill\nCondi\nCostanza\nGeorge\nMargaret\n">>},
+ {"With surrounding context",
+ <<"People: {% regroup people by gender as gender_list %}{% for gender in gender_list %}{{ gender.grouper }}\n{% for item in gender.list %}{{ item.first_name }}\n{% endfor %}{% endfor %}Done.">>,
+ [{people, [[{first_name, "George"}, {gender, "Male"}], [{first_name, "Bill"}, {gender, "Male"}],
+ [{first_name, "Margaret"}, {gender, "Female"}], [{first_name, "Condi"}, {gender, "Female"}]]}],
+ <<"People: Male\nGeorge\nBill\nFemale\nMargaret\nCondi\nDone.">>}
]},
{"spaceless", [
{"Beginning", <<"{% spaceless %} <b>foo</b>{% endspaceless %}">>, [], <<"<b>foo</b>">>},

0 comments on commit c1eebb2

Please sign in to comment.
Something went wrong with that request. Please try again.