Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default formatter for EEx files #1801

Merged
merged 2 commits into from
Jul 31, 2020

Conversation

niknetniko
Copy link
Contributor

@niknetniko niknetniko commented Jul 20, 2020

This PR provides basic support for formatting EEx files.
By basic, I mean that the underlying language is formatted, but the Elixir constructs are not taken into account.

For example, following snippet of HTML:

<html>
<body>
<div>
  <%= if true do %>
    <p>Hallo</p>
    <% end %>
  <p>Test</p>
</div></body></html>

will be formatted as:

<html>
<body>
<div>
    <%= if true do %>
    <p>Hallo</p>
    <% end %>
    <p>Test</p>
</div>
</body>
</html>

As you can see, the content inside the if was not indented. I haven't found an easy way to support this, short of writing a much more complex formatter. As such, I think enabling this will not result in perfect formatting, but it is better then the current situation. Relevant issue is #1594.

Copy link
Owner

@KronicDeth KronicDeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was able to reproduce test case successfully locally in a debug build 👍

@KronicDeth
Copy link
Owner

KronicDeth commented Jul 31, 2020

Fixes #1594

Changelog

Bug Fixes

  • Use SimpleTemplateLanguageFormattingModelBuilder for EEx files, so that the TemplateDataLanguage (i.e. html when the extension is .html.eex) formatter is used instead of the Elixir formatter.

@KronicDeth KronicDeth merged commit 996fc41 into KronicDeth:master Jul 31, 2020
@KronicDeth KronicDeth linked an issue Aug 4, 2020 that may be closed by this pull request
@johannesE
Copy link

Just wanted to say thanks @niknetniko . You made my life a lot more comfortable and productive. Thank you!

@niknetniko niknetniko deleted the feature/eex-formatter branch January 11, 2021 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indentation misalignment in .eex templates
3 participants