How to check for Phoenix.HTML.Safe

Hello!

Is there a way to check if an element is safe to render as HTML? I have a list of items that have a mix of strings, numbers, but also Ecto.Schema.Metadata and I want to be able to ignore the Ecto.Schema.Metadata and render the strings and numbers

Repo.get!(myItem, id)
|> Enum.map(fn {k, v} -> {k, stringify(v)} end)
  defp stringify(list) when is_list(list), do: Enum.reduce(list, "", fn x, acc -> "#{x}, #{acc}" end )
  defp stringify(value), do: value

I was hoping to be able to add another version of stringify that ignores metadata like so:

defp stringify(m) when metadata?(m), do: "not renderable"

Found a solution that works for my use case!

defp stringify(list) when is_list(list) do
    Enum.reduce(list, "", fn x, acc -> "#{x}, #{acc}" end )
  end

  defp stringify(value) when is_number(value), do: value
  defp stringify(value) when is_atom(value), do: value
  defp stringify(value) when is_binary(value), do: value
  defp stringify(value), do: "not renderable"