Contentful Renderer v0.3.0 ContentfulRenderer View Source
Link to this section Summary
Functions
Renders the content inside a node. Useful if you've overriden a renderer, but you don't want to replement how the renderer walks into the content.
Link to this section Functions
Renders a Contentful node, in a tree of Map
s and List
s, to
HTML.
It accepts custom renderers for each node type, passed in as
Keyword
s in the options
parameter. To override the heading-1
renderer, pass in:
heading_1_node_renderer: fn node, options ->
"<h1>#{ContentfulRenderer.render_content(node, options)}</h1>"
end
By default it renders embedded-entry-inline
and
embedded-entry-block
as blank, because these usually require
local knowledge about the content model to render usefully. When
this happens, Logger
will warn.
Examples
iex> %{
...> :content => [
...> %{
...> :content => [
...> %{
...> :data => %{},
...> :marks => [],
...> :nodeType => "text",
...> :value => "Paragraph 1"
...> }
...> ],
...> :data => %{},
...> :nodeType => "paragraph"
...> },
...> %{
...> :content => [
...> %{
...> :data => %{},
...> :marks => [],
...> :nodeType => "text",
...> :value => "Paragraph 2"
...> }
...> ],
...> :data => %{},
...> :nodeType => "paragraph"
...> }
...> ],
...> :data => %{},
...> :nodeType => "document"
...> }
...> |> ContentfulRenderer.render()
"<p>Paragraph 1</p><p>Paragraph 2</p>"
Renders the content inside a node. Useful if you've overriden a renderer, but you don't want to replement how the renderer walks into the content.