sergio

sergio

Phoenix Liveview Templates - automatic formatting using Prettier

Here’s a quick 3 minute video explaining how to get a great workflow for Phoenix Liveview templates. Good dev ux!

First Post!

Nefcairon

Nefcairon

Does it also handle heex?

Most Liked

sergio

sergio

It does, works great! Just make sure you add the file association for .heex templates.

"files.associations": {
  "*.eex": "html-eex",
  "*.leex": "html-eex",
  "*.heex": "html-eex"
},
cvkmohan

cvkmohan

using prettier-plugin-eex has several problems in the formatting. It replaces code with <eext1 /> in many cases.
Further, it does not handle heex files well. For example <link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/assets/app.css")} /> this line generates an error - because href={} is not handled correctly.
If you are using surface, far superior solution is GitHub - surface-ui/surface_formatter · GitHub.
In the upcoming elixir 1.13 release, custom formatters are supported https://github.com/elixir-lang/elixir/pull/11246 - and - we should expect a good elixir formatter that understands both HTML and elixir interpolation should arrive.

Nefcairon

Nefcairon

You can also use it for .sface. It just doesn’t reformat constructs like:

{#for item <- @list}
<h1>Item: {item}</h1>
{#else} No items {/for}

Last Post!

mekusigjinn

mekusigjinn

Any word on this now that 1.13 is out? Okay I’m impatient I understand :smiley: 1.13 is like out for only a few days so I’ll wait more

Where Next?

Popular in Screencasts Top

omgneering
I made follow-up video for getting started with GenServer. This video goes over the syntax of handle_call, handle_cast and handle_info c...
New
Crowdhailer
Tokumei helps with building cloud native web applications. Some of the features that help to make it cloud ready. Containerised by defa...
New
SmartLogic
We at SmartLogic have been running an intermittent series of live coding sessions on Twitch that we then archive on YouTube; in the lates...
New
ElixirCasts
Hello everyone, these are the episodes that are part the Alchemist’s Edition, which is the paid subscription that helps support ElixirCas...
New
whatyouhide
Hey friends, today I published the first video of a new series I’m making, where I solve the challenges on Protohackers (see my tweet ann...
New
plicjo
I created a tutorial for implementing a toggle button in LiveView. It’s been done against Phoenix 1.7 to future-proof it, ...
New
sevensidedmarble
Hey! Here’s a little video I made on how you can start using Neovim for Elixir/Phoenix development: If you like it, pleas...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44778 311
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

We're in Beta

About us Mission Statement