Class: ContentBlockTools::Presenters::BasePresenter
- Inherits:
-
Object
- Object
- ContentBlockTools::Presenters::BasePresenter
- Includes:
- ActionView::Context, ActionView::Helpers::TagHelper
- Defined in:
- lib/content_block_tools/presenters/base_presenter.rb
Direct Known Subclasses
Constant Summary collapse
- BASE_TAG_TYPE =
The default HTML tag to wrap the presented response in - can be overridden in a subclass
:span
- FIELD_PRESENTERS =
A lookup of presenters for particular fields - can be overridden in a subclass
{}.freeze
- BLOCK_PRESENTERS =
A lookup of presenters for particular blocks - can be overridden in a subclass
{}.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content_block) ⇒ {ContentBlockTools::Presenters::BasePresenter}
constructor
Returns a new presenter object.
-
#render ⇒ string
Returns a HTML representation of the content block wrapped in a base tag with a class and data attributes Calls the #content method, which can be overridden in a subclass.
Constructor Details
#initialize(content_block) ⇒ {ContentBlockTools::Presenters::BasePresenter}
Returns a new presenter object
31 32 33 |
# File 'lib/content_block_tools/presenters/base_presenter.rb', line 31 def initialize(content_block) @content_block = content_block end |
Class Method Details
.has_embedded_objects(*object_types) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/content_block_tools/presenters/base_presenter.rb', line 16 def self.(*object_types) @embedded_objects = object_types object_types.each do |object_type| define_method(object_type) do (object_type) end end end |
Instance Method Details
#render ⇒ string
Returns a HTML representation of the content block wrapped in a base tag with a class and data attributes Calls the #content method, which can be overridden in a subclass
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/content_block_tools/presenters/base_presenter.rb', line 40 def render content_tag( base_tag, content, class: %W[content-block content-block--#{document_type}], data: { content_block: "", document_type: document_type, content_id: content_block.content_id, embed_code: content_block., }, ) end |