I want to dynamically render templates from one live view using a single view. I’d like to have a folder structure like
templates
-name
--thing
---index.html.heex
-name
--thing
---index.html.heex
and then render templates depending on the name in the live view something like:
defmodule MyApp.ThingLive.Index do
use MyWeb, :live_view
...
def render(%{name: name} = assigns) do
Phoenix.View.render(MyWeb.ThingView, "#{name}/thing/index.html", assigns)
end
...
end
defmodule MyWeb.ThingView do
use MyWeb, :view
end
I’ve tried doing something like this: How to render a template inside a “web/templates/folder/subfolder” - #6 by chrismccord, but didn’t have any success because it just broke other things.