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"