"mix format" for html.eex and html.leex files?

Is there any mix task (or github repo) that provides formatting of html.eex and html.leex files? It seems like every text editor and IDE has its own weird solution for formatting these files so I wonder is there some ubiquitous tool for formatting these files?

Hello I’m using this one (vscode-eex-format). But it requires to have ruby and its gem " htmlbeautifier" installed to work.

For the job it does I think it’s worth it.

2 Likes

This is good because it can be run from the command line and is editor-agnostic.

Unfortunately it requires installing ruby.

@Kurisu Do you have some way of using this in a CI pipeline? I would like to format html.eex file automatically in CI.

1 Like

Writing this for posterity:

Currently I do it using the Ruby Gem htmlbeautifier (thanks @Kurisu) .

To setup:

Install ruby with:

$ asdf plugin-add ruby
$ asdf install ruby 3.0.0-dev
$ asdf global ruby 3.0.0-dev

Open a new shell and:

$ gem install html beautifier

Then to format at any time, do something like this:

$ find lib -name "*.html.*eex" | xargs ~/.asdf/installs/ruby/3.0.0-dev/bin/htmlbeautifier
3 Likes