ream88
Use mix format for arbitrary HTML files
I really like the formatter, was one of the best additions to the Elixir code base ever, and with the support for .heex files, it became my defacto standard formatter. My question now as I tinkered with raw HTML, is there a way to formatted raw (valid) HTML? Running mix format test.html just does nothing. I guess this happens as the formatter does not know about heex files without the proper plugin Phoenix.LiveView.HTMLFormatter, but introducing the plugin also requires me to have a mix project ![]()
Any suggestions?
Most Liked
wojtekmach
Formatters follow this contract mix format — Mix v1.20.2
I think you can write a custom formatter that mostly delegates to the Phoenix one (untested):
defmodule HTMLFormatter do
@behaviour Mix.Tasks.Format
@impl true
def features(_options) do
[sigils: [:H], extensions: [".heex", ".html"]]
end
@impl true
defdelegate format(source, options), to: Phoenix.LiveView.HTMLFormatter
end
edit: oh, if you’d rather not need to have a Mix project, then it might be pretty tricky.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








