defmodule PrimerLive.Helpers.TestHelpers do @moduledoc false @doc ~S""" Tweaks Phoenix.LiveView.HTMLFormatter.format/2 to remove spaces surrounding HTML tags. ## Examples iex> PrimerLive.Helpers.TestHelpers.format_html(" ...>
Content ...>
...> ") "
Content
" iex> PrimerLive.Helpers.TestHelpers.format_html(" ...> ") "" """ def format_html(html) do html |> Phoenix.LiveView.HTMLFormatter.format([]) |> String.replace(~r/\s*\n\s*/, " ") |> String.replace(~r/\s*\<\s*/, "<") |> String.replace(~r/\s*\>\s*/, ">") |> String.trim() end end