Class: ContentBlockTools::Renderer
- Inherits:
-
Object
- Object
- ContentBlockTools::Renderer
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/content_block_tools/renderer.rb
Overview
Renders a ContentBlock to HTML
This class encapsulates the logic for rendering a content block, including determining the appropriate component or presenter to use and wrapping the result in the standard content block markup.
Defined Under Namespace
Classes: UnknownComponentError
Instance Method Summary collapse
-
#initialize(content_block) ⇒ Renderer
constructor
A new instance of Renderer.
-
#render ⇒ String
Renders the content block to HTML.
Constructor Details
#initialize(content_block) ⇒ Renderer
Returns a new instance of Renderer.
17 18 19 |
# File 'lib/content_block_tools/renderer.rb', line 17 def initialize(content_block) @content_block = content_block end |
Instance Method Details
#render ⇒ String
Renders the content block to HTML
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/content_block_tools/renderer.rb', line 24 def render content_tag( base_tag, content, class: %W[content-block content-block--#{content_block.document_type}], data: { content_block: "", document_type: content_block.document_type, content_id: content_block.content_id, embed_code: content_block., }, ) end |