I am looking to add additional layout parameters like the @inner
for the layout. For example @title
for the
For the page title, you can simply pass a value through from your controller:
def edit(conn, params) do
render(conn, "edit.html", page_title: "Edit The Thing")
end
<%= assigns[:page_title] || "Default Title" %>
Note that this uses assigns[:page_title]
instead of @page_title
or assigns.page_title
as they will error if the :page_title
key is not present in assigns.
For including templates (your script example) there is render_existing/3 (and the docs for the same function in the latest version of Phoenix).
The documentation gives a similar example to what you requested so I have copied it here for convenience:
Consider the case where the application layout allows views to dynamically render a section of script tags in the head of the document. Some views may wish to inject certain scripts, while others will not.
<%= render_existing view_module(@conn), "scripts.html", assigns %>
Then the module for the @inner view can decide to provide scripts with either a precompiled template, or by implementing the function directly, ie:
def render("scripts.html", _assigns) do
"