Sure, here is what the html looks like in both cases:
$ elixir heexformat.exs
next_line: "<a href=\"/i\">\n next line\n</a>,\n" <<<<< notice \n just before the closing </a> and ","
same_line: "<a href=\"/i\">\n same line</a>,\n"
, where heexformat.exs is
Mix.install(
[
{:jason, "~> 1.4"},
{:phoenix, "~> 1.6"},
{:phoenix_live_view, "~> 0.18.3"}
],
config: [
phoenix: [json_library: Jason]
]
)
defmodule HeexFormatTest do
use Phoenix.HTML
import Phoenix.Component, only: [sigil_H: 2]
def to_text(h) do
h
|> Phoenix.HTML.Safe.to_iodata()
|> List.to_string()
end
def generate_html_next_line() do
assigns = %{}
~H"""
<%= link to: "/i", method: :get do %>
<%= "next line" %>
<% end %>,
"""
end
def generate_html_same_line() do
assigns = %{}
~H"""
<%= link to: "/i", method: :get do %>
<%= "same line" %><% end %>,
"""
end
end
HeexFormatTest.generate_html_next_line() |> HeexFormatTest.to_text() |> IO.inspect(label: :next_line)
HeexFormatTest.generate_html_same_line() |> HeexFormatTest.to_text() |> IO.inspect(label: :same_line)






















