web-mode
web-mode copied to clipboard
Indentation in case/cond blocks EEx (Elixir)
I think PR for #1005 brokes it.
Example block of code:
<%= cond do %>
<% @filter.min_price && filter.max_price -> %>
both
<% @filter.min_price -> %>
min
<% @filter.max_price -> %>
max
<% end %>
So it should be formatted this way. Right now it indents after each ->
block and looks like:
<%= cond do %>
<% @filter.min_price && filter.max_price -> %>
both
<% @filter.min_price -> %>
min
<% @filter.max_price -> %>
max
<% end %>
Probably parser should check if we inside cond/case block and do not indent in this case.
@ssbb @lukad
what should I do ?
Is -> %>
for anonymous function ?
@fxbois as I know ->
in Elixir is used only for 2 things:
- Anonymous functions
- Branches in
do ... end
blocks.
there is no so much do ... end
blocks with branches support. I think in templates only case
and cond
is used. Is there a way to check for current context? Something like:
"If nearest parent is <%= cond/case ... do %>
then do not increase indentation level"?
@ssbb I can not indent under <% @filter.min_price -> %>
if there is not an ending block
A naive workaround could be to only indent after ->
if it's after an fn ..
.
Can't really help here though. I'm no longer using emacs.