@external_resource for folder / how does embed_templates do it?

I try to do sth like

@external_resrouce "foo/bar/**" # recompile when folder-contents change

which does not work. @external_resource takes a single file.

I can do

defmodule Foo do
  for f <- Path.wildcard("foo/bar/**") do
    @external_resource f
    ...

which works for changes to files - but not for new files.

I know that for example Phoenix.Template.embed_templates can do it (if I add a new template, the module using embed_templates is recompiled). How is this done. I looked at the code, but its a macro I do not understand.

1 Like

mix_recompile does the trick!

5 Likes