Question: I’m working with some html helper functions made with the ~e sigil. It’s not bad for short pieces of code but for bigger ones I’d like to know if it’s somehow possible to write regular .html.eex template files and use them from any other view / template. If this cannot be done without too much of a hassle, could this feature be considered for future releases of phoenix?
You can just call
render from any eex file (or elixir function from the appropriate View namespace) to render any other eex file at that location. What have you tried so far and how did it not work?
For note, the default generator generates a form that is such an external eex, even layout is such an eex that calls ‘your’ main eex template.
Yep, I was missing the “shared templates across views” section of the manual:
Phoenix.Template could actually be enough if you don‘t need a full view module.