Skip to content

Commit 2fd9bd1

Browse files
committed
Allow inline matcher to be strings too
1 parent e47ddea commit 2fd9bd1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ To enable this, a new callback called `annotate_slot/4` was added. Custom implem
250250
* Raise an exception when trying to bind a single DOM element to multiple views (this could happen when accidentally loading your app.js twice) ([#3805](https://github.com/phoenixframework/phoenix_live_view/pull/3805))
251251
* Ensure promise rejections include stack traces ([#3738](https://github.com/phoenixframework/phoenix_live_view/pull/3738))
252252
* Treat form associated custom elements as form inputs ([3823](https://github.com/phoenixframework/phoenix_live_view/pull/3823))
253-
* Add `:inline_matcher` option to `Phoenix.LiveView.HTMLFormatter` which can be configured as a list of regular expressions to evaluate against tag names to treat them as inline ([#3795](https://github.com/phoenixframework/phoenix_live_view/pull/3795))
253+
* Add `:inline_matcher` option to `Phoenix.LiveView.HTMLFormatter` which can be configured as a list of strings and regular expressions to match against tag names to treat them as inline ([#3795](https://github.com/phoenixframework/phoenix_live_view/pull/3795))
254254

255255
## v1.0
256256

lib/phoenix_live_view/html_formatter.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ defmodule Phoenix.LiveView.HTMLFormatter do
6262
6363
* `:inline_matcher` - a list of regular expressions to determine if a component
6464
should be treated as inline.
65-
Defaults to `[~r/link/, ~r/button/]`, which treats any component with `link
65+
Defaults to `["link", "button"]`, which treats any component with `link
6666
or `button` in its name as inline.
6767
Can be disabled by setting it to an empty list.
6868
@@ -237,7 +237,7 @@ defmodule Phoenix.LiveView.HTMLFormatter do
237237
else
238238
line_length = opts[:heex_line_length] || opts[:line_length] || @default_line_length
239239
newlines = :binary.matches(source, ["\r\n", "\n"])
240-
inline_matcher = opts[:inline_matcher] || [~r/link/, ~r/button/]
240+
inline_matcher = opts[:inline_matcher] || ["link", "button"]
241241

242242
opts =
243243
Keyword.update(opts, :attribute_formatters, %{}, fn formatters ->
@@ -575,7 +575,7 @@ defmodule Phoenix.LiveView.HTMLFormatter do
575575

576576
defp inline?(tag_name, inline_elements, inline_matcher) do
577577
tag_name in inline_elements or
578-
Enum.any?(inline_matcher, &Regex.match?(&1, tag_name))
578+
Enum.any?(inline_matcher, &(tag_name =~ &1))
579579
end
580580

581581
defp count_newlines_before_text(binary),

0 commit comments

Comments
 (0)