Class: AttributeSection

Inherits:
Object show all
Defined in:
lib/volt/page/targets/attribute_section.rb

Instance Method Summary collapse

Constructor Details

#initialize(target, binding_name) ⇒ AttributeSection

Returns a new instance of AttributeSection.



7
8
9
10
11
# File 'lib/volt/page/targets/attribute_section.rb', line 7

def initialize(target, binding_name)
  @target = target
  @binding_name = binding_name
  # puts "init attr section on #{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

#removeObject



33
34
35
36
# File 'lib/volt/page/targets/attribute_section.rb', line 33

def remove
  node = @target.find_by_binding_id(@binding_name)
  node.remove
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

  return 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