Biomine.LiveView.TagFormatter (biomine v0.2.0)

Copy Markdown View Source

A Phoenix.LiveView.HTMLFormatter.TagFormatter implementation that formats the contents of <script> tags with Biomine.

This is useful for formatting colocated hooks embedded in .heex templates and ~H sigils.

Setup

Add it as a :tag_formatters entry alongside Phoenix.LiveView.HTMLFormatter in your .formatter.exs file:

[
  plugins: [Phoenix.LiveView.HTMLFormatter],
  tag_formatters: %{script: Biomine.LiveView.TagFormatter},
  inputs: [
    "{mix,.formatter}.exs",
    "{config,lib,test}/**/*.{ex,exs,heex}"
  ]
]

Formatter options can be passed with the :biomine key, same as Biomine.Mix.JsFormatter:

[
  plugins: [Phoenix.LiveView.HTMLFormatter],
  tag_formatters: %{script: Biomine.LiveView.TagFormatter},
  biomine: [quote_style: :single, semicolons: :as_needed],
  inputs: [
    "{mix,.formatter}.exs",
    "{config,lib,test}/**/*.{ex,exs,heex}"
  ]
]