-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Environment
- Elixir & Erlang/OTP versions (elixir --version): Erlang/OTP 24, Elixir 1.12.1
- Operating system: Fedora 35
Current behavior
The following EEx template doesn't compile when a comment lies between the case/cond do
and the first clause. I would expect blocks starting with <%#
to be ignored by the compiler and not interpreted as an expression.
EEx.compile_string("""
<%= case true do %>
<%# comment %>
<% true -> %>
false
<% false -> %>
true
<% end %>
""")
** (SyntaxError) nofile:4: unexpected operator ->. If you want to define multiple clauses, the first expression must use ->. Syntax error before: '->'
If the comment is placed in the first clause (or anytime later), it works properly.
EEx.compile_string("""
<%= case true do %>
<% true -> %>
<%# comment %>
false
<% false -> %>
true
<% end %>
""")
Expected behavior
I would expect a similar behavior than:
case true do
# comment
true -> true
false -> false
end
It can make sense to put a comment to explain what this clause means before the clause itself.
Possibly related: #10256