Class: Volt::AttributeSection
- Inherits:
-
BaseSection
- Object
- BaseSection
- Volt::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, #set_template
Constructor Details
#initialize(target, binding_name) ⇒ AttributeSection
Returns a new instance of AttributeSection.
8 9 10 11 |
# File 'lib/volt/page/targets/attribute_section.rb', line 8 def initialize(target, binding_name) @target = target @binding_name = binding_name end |
Instance Method Details
#html=(value) ⇒ Object
17 18 19 |
# File 'lib/volt/page/targets/attribute_section.rb', line 17 def html=(value) set_content_and_rezero_bindings(value, {}) end |
#remove ⇒ Object
33 34 35 36 37 |
# File 'lib/volt/page/targets/attribute_section.rb', line 33 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
23 24 25 26 27 28 29 30 31 |
# File 'lib/volt/page/targets/attribute_section.rb', line 23 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 bindings end |
#text=(text) ⇒ Object
13 14 15 |
# File 'lib/volt/page/targets/attribute_section.rb', line 13 def text=(text) set_content_and_rezero_bindings(text, {}) end |