I am currently using Phoenix.Template.render(ChatWeb.ThemeView, "chat_window_live_component", "html", assigns)
to render the HTML for all my components. In my view class (ChatWeb.ThemeView
), I have the following structure:
elixirCopy code
defmodule ChatWeb.ThemeView do
use ChatWeb, :html
embed_templates "**/*", root: "templates/default/"
end
I am facing an issue where I need to change the root path dynamically based on a selected theme. Unfortunately, I cannot find a way to add a condition based on an assign
or a socket
value.
Problem:
I need to change the root
path dynamically in the embed_templates
function based on a selected theme. For example, if the user selects the “dark” theme, I want the root path to be “templates/dark/”. If they select the “light” theme, I want it to be “templates/light/”.
Request for Support:
I need assistance in finding a solution to dynamically change the root path in the embed_templates
function based on a selected theme. Is there a way to achieve this using assigns or socket values?