How to render a component gotten from the database

Hey, I am building a CMS at the moment. Workflow is like this: An Admin is able to create a new page so he fills out a form. The body field of this form can contain either components we have in our system or plain text. The text and component fields are saved in the database as components of this page.
At the moment, when reading from the db, the components are displayed as text. What do i have to do to resolve the text to the actual component.

The page.ex file, where i retrieve the specific page and display it. It’s a live_view. I am calling component.content here because that is where my components/text is stored in.

  @impl true
  def render(assigns) do
      <div class="">

        <%= for component <- @page.components do %>
          <%= (render_component here ? )component.content %>
        <% end %>

As a result, I get this <.faqcontainer> test <.faqcontainer> printed on my page.
I want the contents from the two faqcontainer’s instead. Basically i want to display the components, not their names.

Thanks a lot


Could you share an example of @page.components/component – e.g. output of IO.inspect?

There was some previous discussion on dynamically rendering components here:

Thanks, will look into this thread and reply again it it wont solve my question :slight_smile: