Sha256: bc0e6ef51fe6ae48917eb82d0e246cd3cf80777a646b7f68b310e6147e737760

Contents?: true

Size: 556 Bytes

Versions: 8

Compression:

Stored size: 556 Bytes

Contents

require_relative '../base_node_renderer'

module RichTextRenderer
  # Base renderer for block type nodes
  class BaseBlockRenderer < BaseNodeRenderer
    # Renders block type nodes.
    def render(node)
      "<#{render_tag}>#{render_content(node)}</#{render_tag}>"
    end

    protected

    def render_content(node)
      node['content'].each_with_object([]) do |content_node, result|
        renderer = find_renderer(content_node)
        result << renderer.render(content_node)
      end.join
    end

    def render_tag
      'div'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rich_text_renderer-0.3.2 lib/rich_text_renderer/block_renderers/base_block_renderer.rb
rich_text_renderer-0.3.1 lib/rich_text_renderer/block_renderers/base_block_renderer.rb
rich_text_renderer-0.3.0 lib/rich_text_renderer/block_renderers/base_block_renderer.rb
rich_text_renderer-0.2.3 lib/rich_text_renderer/block_renderers/base_block_renderer.rb
rich_text_renderer-0.2.2 lib/rich_text_renderer/block_renderers/base_block_renderer.rb
rich_text_renderer-0.2.1 lib/rich_text_renderer/block_renderers/base_block_renderer.rb
rich_text_renderer-0.2.0 lib/rich_text_renderer/block_renderers/base_block_renderer.rb
rich_text_renderer-0.1.0 lib/rich_text_renderer/block_renderers/base_block_renderer.rb