Class: ShelfTag
- Defined in:
- lib/objective_elements/shelf_tag.rb
Overview
This is a nonexistent HTML tag, which holds content like a double tag but has no opening or closing tag. This allows us to group siblings without adding an extra parent to the markup.
Instance Attribute Summary
Attributes inherited from DoubleTag
Attributes inherited from SingleTag
Instance Method Summary collapse
- #add_parent(parent) ⇒ Object
-
#initialize(content: nil, oneline: false) ⇒ ShelfTag
constructor
A shelf has no element of its own, so it never renders an opening tag.
- #to_a ⇒ Object
Methods inherited from DoubleTag
#add_content, #reset_content, #to_s
Methods inherited from SingleTag
#method_missing, #reset_attributes, #respond_to_missing?, #to_s
Constructor Details
#initialize(content: nil, oneline: false) ⇒ ShelfTag
A shelf has no element of its own, so it never renders an opening tag.
8 9 10 |
# File 'lib/objective_elements/shelf_tag.rb', line 8 def initialize(content: nil, oneline: false) super(nil, content: content, oneline: oneline) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SingleTag
Instance Method Details
#add_parent(parent) ⇒ Object
16 17 18 |
# File 'lib/objective_elements/shelf_tag.rb', line 16 def add_parent(parent) parent.add_content content end |
#to_a ⇒ Object
12 13 14 |
# File 'lib/objective_elements/shelf_tag.rb', line 12 def to_a content.map { |c| build_content_line c }.flatten end |