Current section

Files

Jump to
project lib mix tasks project remove live_title_suffix.ex
Raw

lib/mix/tasks/project/remove/live_title_suffix.ex

defmodule Mix.Tasks.Project.Remove.LiveTitleSuffix do
@shortdoc "Removes live title suffix"
@moduledoc "Removes the live title suffix."
use Igniter.Mix.Task
alias Mix.Tasks.Project.Helpers
@impl Igniter.Mix.Task
def igniter(igniter) do
app_web = Helpers.app_web_module(igniter) |> Macro.underscore()
path = "lib/#{app_web}/components/layouts/root.html.heex"
Helpers.update_file_content(igniter, path, fn content ->
String.replace(
content,
~r/<\.live_title([^>]*) suffix="[^"]*"([^>]*)>\s*(\{[^}]+\})\s*<\/\.live_title>/s,
"<.live_title\\1\\2>\\3</.live_title>"
)
end)
end
end