Skip to content

Commit 0267f31

Browse files
author
José Valim
committed
Fix handling of nested do expressions in EEx, closes #1710
1 parent 8a45ca8 commit 0267f31

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/eex/lib/eex/compiler.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defmodule EEx.Compiler do
3131
defp generate_buffer([{ :start_expr, line, mark, chars }|t], buffer, scope, state) do
3232
{ contents, t } = generate_buffer(t, "", [chars|scope], state.dict([]).line(line).start_line(line))
3333
buffer = state.engine.handle_expr(buffer, mark, contents)
34-
generate_buffer(t, buffer, scope, state.dict([]))
34+
generate_buffer(t, buffer, scope, state)
3535
end
3636

3737
defp generate_buffer([{ :middle_expr, line, _, chars }|t], buffer, [current|scope], state) do

lib/eex/test/eex_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,21 @@ foo
264264
assert_eval expected, string
265265
end
266266

267+
test "evaluates nested do expressions" do
268+
string = """
269+
<% y = ["a", "b", "c"] %>
270+
<%= cond do %>
271+
<% "a" in y -> %>
272+
Good
273+
<% true -> %>
274+
<% if true do %>true<% else %>false<% end %>
275+
Bad
276+
<% end %>
277+
"""
278+
279+
assert_eval "\n\n Good\n \n", string
280+
end
281+
267282
test "unicode" do
268283
template = """
269284
• <%= "•" %> •

0 commit comments

Comments
 (0)