Understanding Mix.Tasks.New: where are the functions?

I was looking to learn a bit more about customizing Mix generators – I was able to customize the Phoenix generators (phx.new et al) without too much trouble. But once I looked at the humble mix new code in Mix.Tasks.New, I got confused. There are a handful of functions in there (e.g. readme_template/1, mix_exs_template/1 etc) that don’t seem to be defined anywhere – e.g. not in the Mix.Generator module. They don’t seem to be macros either. How does this code execute? Can someone explain the mystery there? I asked in the Slack too, but I figured this might make a good forum post for future reference. Thanks in advance!

Looks like that’s set up by the embed_template(:readme, """... call which uses Mix.Generator.embed_template/2 that runs EEx.function_from_string

2 Likes