js-beautify icon indicating copy to clipboard operation
js-beautify copied to clipboard

Support for `.html.heex`

Open NatoBoram opened this issue 3 years ago • 0 comments

Description

Phoenix is a web framework in Elixir which uses some special server-side HTML tags.

Right now, the result is pretty good. I think the only missing thing is adding an indent level when there's a do %> and removing one when there's an <% end %>. These special tags can be opened by either <%= or <%.

There's a large demand for this feature spanning many projects :

  • https://github.com/adamzapasnik/prettier-plugin-eex/issues/71
  • https://github.com/beautify-web/js-beautify/issues/1964
  • https://github.com/elixir-lsp/vscode-elixir-ls/issues/162
  • https://github.com/elixir-lsp/vscode-elixir-ls/issues/201
  • https://github.com/elixir-lsp/vscode-elixir-ls/issues/98
  • https://github.com/elixir-lsp/vscode-elixir-ls/pull/193
  • https://github.com/phoenixframework/vscode-phoenix/issues/6
  • https://github.com/prettier/prettier/issues/12269

Input

With this new feature, when I give like this input:

<%= submit class: "btn btn-outline-primary" do %>
<%= gettext("Create") %>
<% end %>
<%= if @component do %>
<%= for dep <- @component.dependencies() do %>
<.live_component module={dep} id={dep.id()} />
<% end %>
<% end %>

Expected Output

I'd like to see this output:

<%= submit class: "btn btn-outline-primary" do %>
  <%= gettext("Create") %>
<% end %>
<%= if @component do %>
  <%= for dep <- @component.dependencies() do %>
    <.live_component module={dep} id={dep.id()} />
  <% end %>
<% end %>

Environment

OS: Pop!_OS 21.04 x86_64

NatoBoram avatar Nov 18 '21 21:11 NatoBoram