Class: AttributeSection

Inherits:
Object show all
Defined in:
lib/volt/templates/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/templates/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

#removeObject



29
30
31
32
# File 'lib/volt/templates/targets/attribute_section.rb', line 29

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



19
20
21
22
23
24
25
26
27
# File 'lib/volt/templates/targets/attribute_section.rb', line 19

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/templates/targets/attribute_section.rb', line 13

def text=(text)
  set_content_and_rezero_bindings(text, {})
end