Generating modules, templates and maybe injecting some code into specific Phoenix project files

Please can you help me going into the right direction?
I can see that many packages have mix tasks for generating various files into Phoenix project or injecting some code into existing files.

Basically what I want to do is to create by running some command some views modules or helpers that I use in most of my projects. I will have also to replace for example MyAppWeb by DemoWeb in the generated files. And It will be great if I can inject code that import or alias them into specific Phoenix module.

What are the right tools to achieve that? Any guide or tutorial will be welcome.

Thanks

Phoenix’s commands just use EEX (built in to elixir) to generate such files, you can do the same pretty easily. Phoenix also let’s you override it’s templates with your own as well.

3 Likes

You might find in this project an example of how they did it.

It is a package that injects templates from priv/templates/thesis.install, and uses custom mix task (in lib/mix/tasks/)

2 Likes