Class: ContentBlockTools::Presenters::BasePresenter
- Inherits:
-
Object
- Object
- ContentBlockTools::Presenters::BasePresenter
- Includes:
- 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
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
14 15 16 |
# File 'lib/content_block_tools/presenters/base_presenter.rb', line 14 def initialize(content_block) @content_block = content_block 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
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/content_block_tools/presenters/base_presenter.rb', line 23 def render content_tag( BASE_TAG_TYPE, content, class: %W[content-embed content-embed__#{content_block.document_type}], data: { content_block: "", document_type: content_block.document_type, content_id: content_block.content_id, }, ) end |