-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Raising this issue as requested as per the mailing list https://groups.google.com/forum/#!topic/elixir-lang-talk/keFkzq-cs18
The issue can be seen when using a nested do/end tag within a cond macro in a EEx template. Its a little tricky to explain so the following unit test shows the problem. Basically the first test "nested cond" passes as expected, the second test "nested cond with end" containing a if/else macro fails returning what seems to be the value in the last case statement containing a do/end macro (in this case if/else/end). Hopefully that makes sense along with the unit test below.
ExUnit.start [trace: "--trace" in System.argv]
defmodule CondTest do
use ExUnit.Case
test "nested cond" do
str = """
<% y = ["a", "b", "c"] %>
<% x = [1, 2, 3] %>
<%= cond do %>
<% "a" in y -> %> <%# this matches as expected %>
Good
<% 1 in x -> %>
Weird
<% true -> %>
Bad
<% end %>
"""
assert "Good" === String.strip( EEx.eval_string(str, args: []) )
end
test "nested cond with end" do
str = """
<% y = ["a", "b", "c"] %>
<% x = [1, 2, 3] %>
<%= cond do %>
<% "a" in y -> %> <%# this doesnt match the last case below conatining an end tag does ? %>
Good
<% "b" in y -> %>
<% if true do %>True<% else %>false<% end %>
Weird2
<% 1 in x -> %>
<% if true do %>True<% else %>false<% end %>
Weird
<% 1 == 2 -> %>
Weird3
<% true -> %>
Bad
<% end %>
"""
assert "Good" === String.strip( EEx.eval_string(str, args: []) )
end
end
Thanks,
Andy.
Metadata
Metadata
Assignees
Labels
No labels