From my layout (app.html.eex
file) I want to render a template that is inside a subfolder (2nd level folder) in my templates folder (sample structure):
/templates/layout
/templates/layout_module/header_footer/fad.html.eex
I have views for all 1st level folders (layout, layout_module,...
).
I'm using:
<%= render FabricaASA.Layout_moduleView, "/header_footer/fad.html" %>
I've tried a few alternatives with no success. What's the best way of doing it?
I got the answer from Chris McCord (creator of PhoenixFramework) here: https://elixirforum.com/t/how-to-render-a-template-inside-a-web-templates-folder-subfolder/1404
In web.ex
file add the pattern
option:
use Phoenix.View, root: "web/templates", pattern: "**/*"
Then just use:
<%= render FabricaASA.Layout_moduleView, "header_footer/fad.html" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With