Class: StructuredTextRenderer::Renderer

Inherits:
BaseNodeRenderer show all
Defined in:
lib/structured_text_renderer/renderer.rb

Overview

Renderer for StructuredText field from Contentful

Constant Summary collapse

DEFAULT_MAPPINGS =

Default Renderers

{
  nil => NullRenderer,
  'document' => DocumentRenderer,
  'heading-1' => HeadingOneRenderer,
  'heading-2' => HeadingTwoRenderer,
  'heading-3' => HeadingThreeRenderer,
  'heading-4' => HeadingFourRenderer,
  'heading-5' => HeadingFiveRenderer,
  'heading-6' => HeadingSixRenderer,
  'quote' => QuoteRenderer,
  'hyperlink' => HyperlinkRenderer,
  'paragraph' => ParagraphRenderer,
  'list-item' => ListItemRenderer,
  'ordered-list' => OrderedListRenderer,
  'unordered-list' => UnorderedListRenderer,
  'embedded-entry-block' => EntryBlockRenderer,
  'hr' => HrRenderer,
  'text' => TextRenderer,
  'bold' => BoldRenderer,
  'code' => CodeRenderer,
  'italic' => ItalicRenderer,
  'underline' => UnderlineRenderer
}

Instance Attribute Summary

Attributes inherited from BaseNodeRenderer

#mappings

Instance Method Summary collapse

Constructor Details

#initialize(mappings = {}) ⇒ Renderer

Returns a new instance of Renderer



36
37
38
# File 'lib/structured_text_renderer/renderer.rb', line 36

def initialize(mappings = {})
  @mappings = DEFAULT_MAPPINGS.merge(mappings)
end

Instance Method Details

#render(document) ⇒ Object

Returns a rendered StructuredText document



41
42
43
44
# File 'lib/structured_text_renderer/renderer.rb', line 41

def render(document)
  renderer = find_renderer(document)
  renderer.render(document) unless renderer.nil?
end