Sha256: cf9b6d41e2c8f5e8c483e27405b517c2e88d108c6758ebce8f5352b0e431f034
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
require_relative './text_renderers' require_relative './block_renderers' require_relative './document_renderers' require_relative './base_node_renderer' require_relative './null_renderer' # RichTextRenderer Namespace module RichTextRenderer # Renderer for RichText field from Contentful class Renderer < BaseNodeRenderer # Default Renderers DEFAULT_MAPPINGS = { nil => NullRenderer, 'document' => DocumentRenderer, 'heading-1' => HeadingOneRenderer, 'heading-2' => HeadingTwoRenderer, 'heading-3' => HeadingThreeRenderer, 'heading-4' => HeadingFourRenderer, 'heading-5' => HeadingFiveRenderer, 'heading-6' => HeadingSixRenderer, 'blockquote' => BlockQuoteRenderer, 'hyperlink' => HyperlinkRenderer, 'paragraph' => ParagraphRenderer, 'list-item' => ListItemRenderer, 'ordered-list' => OrderedListRenderer, 'unordered-list' => UnorderedListRenderer, 'embedded-entry-block' => EntryBlockRenderer, 'embedded-asset-block' => AssetBlockRenderer, 'asset-hyperlink' => AssetHyperlinkRenderer, 'hr' => HrRenderer, 'text' => TextRenderer, 'bold' => BoldRenderer, 'code' => CodeRenderer, 'italic' => ItalicRenderer, 'underline' => UnderlineRenderer, 'table' => TableRenderer, 'table-row' => TableRowRenderer, 'table-cell' => TableCellRenderer, 'table-header-cell' => TableHeaderCellRenderer } def initialize(mappings = {}) @mappings = DEFAULT_MAPPINGS.merge(mappings) end # Returns a rendered RichText document def render(document) renderer = find_renderer(document) renderer.render(document) unless renderer.nil? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rich_text_renderer-0.3.1 | lib/rich_text_renderer/renderer.rb |
rich_text_renderer-0.3.0 | lib/rich_text_renderer/renderer.rb |