How to nest many templates

web/templates/layout/app.html.eex
web/templates/registration/registration-process.html.eex
web/templates/registration/individual/personal-information/new.html.eex
web/templates/registration/group/personal-information/new.html.eex

I’d like to render in the ‘individual/personal-information’ controller the following nested set of templates:

layout/app.html.eex -> registration/registration-process -> registration/individual/personal-information/new.html

and in the ‘group/group-information’ controller the following nested set of templates
layout/app.html.eex -> registration/registration-process -> registration/group/personal-information/new.html

I’m having trouble thinking about how to set up these views / layouts.

1 Like

Hi Shawn,
This may or may not help you since I’m still on a steep learning curve myself.
The controller will render your parent template:

render conn, "my_master_template.html", mykey: value

To render a template inside a template use something like this in the parent template:

<%= render MyApp.MyView, "partial.html", conn: @conn, key: @mykey %>

You have to pass forward the data you want your templates to use as key/values.

1 Like

Thanks for the reply. I guess that what helped me the most was figuring out that the .eex was turned into a function in the view module at compile time.