Nefcairon

Nefcairon

Hello,

Should the command Code > Reformat code (Ctrl-Alt-L) oder Code > Auto-Intend Lines (Crtl-Alt-I) work with .html.eex files when using IntelliJ plugin intellij-elixir? If yes, do I have to change or set up anything?

Sorry if I should have posted in the IntelliJ Elixir - Elixir plugin for JetBrain’s IntelliJ Platform topic.

Thanks,
Peter

Showing Posts 1 to 10

Nefcairon

Nefcairon OP

@KronicDeth Can you help?

KronicDeth

KronicDeth

The formatter is registered for Elixir

https://github.com/KronicDeth/intellij-elixir/blob/88733a74968dd789b6809777626f8bd68a72562e/resources/META-INF/plugin.xml#L154

not EEx, so I think if it works at all, it would format the Elixir inside the EEx tags.

I’m not sure how formatting a whole file works since the outer (HTML) needs to be formatted, then the template tags (EEx) and then the inner (Elixir). IntelliJ Ultimate Edition, WebStorm, PHPStorm, and Rubymine have HTML formatters I think, so they should format the HTML, but I don’t think HTML support is in IntelliJ Community Edition.

So, maybe I need to register a formatter for EEx too, but I’m not sure how that would work since you can put the tags wherever, like to interpolate an attribute or even seemly invalid, partial HTML and that formatting would be dependent on the outer language.

Which IDEs have you tried Auto-Indent Lines in?

Nefcairon

Nefcairon OP

@KronicDeth Thanks for your reply.

I’m using IntelliJ Idea’s Ultimate Version. Trying ‘auto-intend lines’ and nothing happens on html.eex files. Can I register a formatter for EEx myself?

drl123

drl123

FWIW I use Rubymine for editing Elixir/Phoenix code. I had to add *.html.eex under eex to get it to treat those as both HTML and EEX for highlighting and Zen coding HTML. However it will not respect the Elixir blocks that span <%= %> tags for reformatting or indenting. I’ve just been applying the formatting manually. I wasn’t sure if this was just a small-IDE thing or not until I saw your post. Maybe it does need a formatter registered since, unlike .ex or .exs files, the code it separated by tags in .html.eex.

It also complains that it can’t find the definition/assignment of the assigns variables and doesn’t bold the name (@current_user, etc), but that’s just a minor inconvenience.

For the most part, the plugin is awesome. Kudos to @KronicDeth for all of the great work and being so responsive to questions.

kurtome

kurtome

Love the Elixir plugin so much, except for this. It’s driving me crazy that I can’t format HTML files, I’ve tried fiddling with all the options in IntelliJ and it seems to just completely ignore indenting for .html.eex files no matter what I do.

Thanks for the plugin though @KronicDeth

edit: just found the best work-around: rename the file to .html for a second, reformat it, rename it back to .html.eex

JorisKok

JorisKok

I am using PhpStorm and got it working with adding *.html.eex under the Editor > File Types > Twig. As it has a similar template language style, it works like a charm.

joe

joe

If anyone ever finds a better solution than the Twig file type, please please please tell me here. It’s still driving me crazy because now I basically have the option which language it’s properly formatting but not both…

niknetniko

niknetniko

The Elixir plugin was recently updated to provide better formatting (as of v11.8.0). It will now use the underlying language for eex files, meaning *.html.eex files will be formatted as HTML. Unfortunately, this still won’t format both Elixir and HTML at the same time. An example of what I mean:

<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.

drl123

drl123

I’m using it with Rubymine and if you add *.html.eex and set the template language to HTML, it formats both the HTML and Elixir as you can see below. This has been my pet peeve for a while but seems to be resolved with the latest update!

joe

joe

On your screenshot you have set the language of *.html.eex to Embedded Elixir, no?

Your highlighting seems correct (in contrast to @niknetniko’s answer). Is that Rubymine specific? Because I want that! :sweat_smile:

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews