How do you recreate the base HTML templates in Phoenix?

I stripped all the HTML templates, views, and layouts out of my Phoenix app years ago because it’s just been an API. I’m now converting it to a Phoenix LiveView app.

Is there a way to recreate the base templates and layouts for Phoenix? I know you can run a generator again to recreate a context/schema/views, but what about the base? I’m hoping to do this once Phoenix 1.7 goes live.

Thanks!

I don’t know of a command offhand, but Phoenixdiff could at least provide some pointers about where to dig:

Create a fresh project in a different folder and run generators like mix phx.gen.live and see what folders it has created and default files it created. You can start from there and copy relevant files.

If you create the fresh project with same name - it will be easy to migrate as the module names will have same naming convention as your existing project.

1 Like

Aah, ok- so there isn’t a generator I can re-run. Yeah using a fresh project sounds like the cleanest solution.

Thanks!

1 Like

You can actually call mix phx.new in a new git branch and it’ll add the missing files + overwrite the existing files. And then you can go through git diff (or whatever other tool you use) and see how it differs.

if you want to test this behaviour:

mix phx.new test --no-html
cd test
git init
git add .
git commit -m "Init"
mix phx.new . test
3 Likes

Oh nice- I hadn’t thought of just running phx.new again in the same project. That’s perfect, thank you!

1 Like