defmodule HistoryWeb.DataView do use HistoryWeb, :view import Phoenix.HTML.Link def render("_breadcrumbs.html", assigns) do indexed_sections = assigns.section |> List.wrap() |> Enum.with_index() ~E"""

<%= Enum.map(indexed_sections, &render_breadcrumb_section/1) %>

""" end def render("_header.html", assigns) do sections = ["Data" | assigns.section] assigns = Map.put(assigns, :section, sections) render("_breadcrumbs.html", assigns) end def render("_nav.html", assigns) do ~E""" """ end defp render_breadcrumb_section({{section, to}, index}) do text = if index > 0, do: "/#{section}", else: section link(text, to: to, class: "opacity-70 hover:opacity-50") end defp render_breadcrumb_section({section, index}) when index > 0, do: "/#{section}" defp render_breadcrumb_section({section, _}), do: section end