Programming Phoenix LiveView B10.0: Customizing Phoenix templates (page 101)

In “Examine the Generated Code,” the book explains that mix phx.gen.live uses templates in deps/phoenix/priv/templates/phx.gen.live to generate application modules (.ex), scripts (.exs), and templates (.heex). The book shows the header function from core_components.ex as an example.

Programmers can modify the generated files to meet their application’s needs, to match website CSS styling, for example. Similar modifications may be needed in several generated files (products, customers, etc.).

I suggest mentioning that the Phoenix generator templates themselves can be modified. Mark Ericksen’s blog post “Customizing Phoenix Generators” provides the details. Briefly, any Phoenix generator template file can be copied from deps/phoenix/priv/templates/phx.gen.xxx/ directory to the project’s priv/templates/phx.gen.xxx/ directory. A programmer can modify the template copy as needed. Phoenix generators will use available project templates instead of generic templates.