feliperenan

feliperenan

Hi people :wave:

We have been working on a Formatter to format Heex templates. The idea is to have a similar experience as we do when formatting Elixir code :).

Please, we’d love if you try it out and let us know any feedback you have. In the repo, you can find the instructions on how to install and use it and, here you can see how it is supposed to format.

Here is the Repo link: GitHub - feliperenan/heex_formatter: Formatter for Phoenix Live View templates. · GitHub

Thank you

Showing Posts 1 to 10

cvkmohan

cvkmohan

Welcome @feliperenan !!!
I have been very vocal about this library here already. Formatter for HEEx templates - #12 by cvkmohan

Friends, this library made my vscode setup leaner ( I was using beautify and more extensions earlier.) and @feliperenan has been very responsive to attend to my queries. A big applause.

andreaseriksson

andreaseriksson

Im testing this in a new phoenix app and when I try

mix format lib/test_crm_web/live/customer_live/index.html.heex

I get the error:

lib/test_crm_web/live/customer_live/index.html.heex:1:1: syntax error before: '<'

I have done nothing else than generated a live resource. Is there anything I missed?

josevalim

josevalim

Creator of Elixir

What is your Elixir and Phoenix.LiveView versions? Do you also have a full stacktrace? I am wondering if it is trying to run the Elixir formatter on that .heex file.

andreaseriksson

andreaseriksson

I was trying to run it on that heex file.
LiveView 0.17.6
Elixir 1.12.1

mix format failed for file: lib/test_crm_web/live/customer_live/index.html.heex
** (SyntaxError) lib/test_crm_web/live/customer_live/index.html.heex:1:1: syntax error before: '<'
    (elixir 1.12.1) lib/code.ex:978: Code.format_string!/2
    (mix 1.12.1) lib/mix/tasks/format.ex:418: Mix.Tasks.Format.format_file/2
    (elixir 1.12.1) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.12.1) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.13.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
josevalim

josevalim

Creator of Elixir

You need at least Elixir v1.13! You should even get a warning printed by using an earlier version. :slight_smile:

feliperenan

feliperenan OP

I’m not sure if that works on Elixir 1.12 since format plugins are a thing only after Elixir 1.13. Please, try to update your Elixir and let us know If you have any other issues, it would be nice if you could share the template you are trying to format in case you are still facing issues :raised_hands:.

andreaseriksson

andreaseriksson

All good. It works after updating elixir version.

soup

soup

Seems to depend on LiveViews master, instead of a versioned release? Or is this my configuration at fault?

  #mix.exs
  {:phoenix_live_view, "~> 0.17"},
  {:heex_formatter, github: "feliperenan/heex_formatter", only: [:dev]}
λ mix deps.get
* Getting heex_formatter (https://github.com/feliperenan/heex_formatter.git)
remote: Enumerating objects: 492, done.
remote: Counting objects: 100% (492/492), done.
remote: Compressing objects: 100% (254/254), done.
remote: Total 492 (delta 207), reused 485 (delta 200), pack-reused 0
origin/HEAD set to main
Dependencies have diverged:
* phoenix_live_view (Hex package)
  the dependency phoenix_live_view in mix.exs is overriding a child dependency:

  > In mix.exs:
    {:phoenix_live_view, "~> 0.17", [env: :prod, repo: "hexpm", hex: "phoenix_live_view"]}

  > In deps/heex_formatter/mix.exs:
    {:phoenix_live_view, [only: [:dev], env: :prod, git: "https://github.com/phoenixframework/phoenix_live_view.git"]}

  Ensure they match or specify one of the above in your deps and set "override: true"
** (Mix) Can't continue due to errors on dependencies

Rather not mark LV with override, but I get that this is pre-release.

feliperenan

feliperenan OP

Yes. At the moment heex formatter depends on live view master and I’m afraid you have to use override:true in your mix.exs.

axelson

axelson

Scenic Core Team

For anyone following this thread, heex formatter no longer relies on live view master. Instead as of Update mix.exs by cvkmohan · Pull Request #52 · feliperenan/heex_formatter · GitHub it relies on liveview 0.17.7 or higher.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews