Skip to content

How to use custom templates

Scott Swezey edited this page Oct 5, 2018 · 1 revision

You could use Phoenix.View.render to render any template as a string and put it to the dashboard:

defmodule Demo.ExAdmin.Dashboard do
  use ExAdmin.Register

  register_page "Dashboard" do
    menu priority: 1, label: "Dashboard"
    content do
      Phoenix.View.render(Demo.PageView, "index.html", [])
      |> Phoenix.HTML.safe_to_string
      |> raw
    end
  end
end

Also you could use custom templates at other pages, just use panel macro like in an example:

  register_resource Category do
    show category do
      panel "ExAdmin Demo" do
        markup_contents do
          Phoenix.View.render(Demo.CategoryView, "into.html", [category: category])
          |> Phoenix.HTML.safe_to_string
          |> raw
        end
      end
    end
  end