Class: AttributeSection
- Inherits:
-
BaseSection
- Object
- BaseSection
- AttributeSection
- Defined in:
- lib/volt/page/targets/attribute_section.rb
Instance Method Summary collapse
- #html=(value) ⇒ Object
-
#initialize(target, binding_name) ⇒ AttributeSection
constructor
A new instance of AttributeSection.
- #remove ⇒ Object
-
#set_content_and_rezero_bindings(html, bindings) ⇒ Object
Takes in our html and bindings, and rezero’s the comment names, and the bindings.
- #text=(text) ⇒ Object
Methods inherited from BaseSection
#insert_anchor_before_end, #remove_anchors, #set_content_to_template
Constructor Details
#initialize(target, binding_name) ⇒ AttributeSection
Returns a new instance of AttributeSection.
7 8 9 10 |
# File 'lib/volt/page/targets/attribute_section.rb', line 7 def initialize(target, binding_name) @target = target @binding_name = binding_name end |
Instance Method Details
#html=(value) ⇒ Object
16 17 18 |
# File 'lib/volt/page/targets/attribute_section.rb', line 16 def html=(value) set_content_and_rezero_bindings(value, {}) end |
#remove ⇒ Object
32 33 34 35 36 |
# File 'lib/volt/page/targets/attribute_section.rb', line 32 def remove # TODO: is this getting run for no reason? node = @target.find_by_binding_id(@binding_name) node.remove if node end |
#set_content_and_rezero_bindings(html, bindings) ⇒ Object
Takes in our html and bindings, and rezero’s the comment names, and the bindings. Returns an updated bindings hash
22 23 24 25 26 27 28 29 30 |
# File 'lib/volt/page/targets/attribute_section.rb', line 22 def set_content_and_rezero_bindings(html, bindings) if @binding_name == 'main' @target.html = html else @target.find_by_binding_id(@binding_name).html = html end return bindings end |
#text=(text) ⇒ Object
12 13 14 |
# File 'lib/volt/page/targets/attribute_section.rb', line 12 def text=(text) set_content_and_rezero_bindings(text, {}) end |