mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
18 lines
491 B
Elixir
18 lines
491 B
Elixir
defmodule PhilomenaWeb.TextRenderer do
|
|
alias PhilomenaWeb.TextileRenderer
|
|
alias PhilomenaWeb.MarkdownRenderer
|
|
|
|
def render_one(item, conn) do
|
|
hd(render_collection([item], conn))
|
|
end
|
|
|
|
def render_collection(items, conn) do
|
|
Enum.map(items, fn item ->
|
|
if Map.has_key?(item, :body_md) && item.body_md != nil && item.body_md != "" do
|
|
MarkdownRenderer.render(item.body_md, conn)
|
|
else
|
|
TextileRenderer.render(item.body, conn)
|
|
end
|
|
end)
|
|
end
|
|
end
|