Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render a template inside a "web/templates/folder/subfolder"

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?

like image 890
Paulo Janeiro Avatar asked Aug 19 '16 16:08

Paulo Janeiro


1 Answers

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" %>
like image 173
Paulo Janeiro Avatar answered Sep 24 '22 06:09

Paulo Janeiro