Class: Volt::BaseSection

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

Overview

Class to describe the interface for sections

Direct Known Subclasses

AttributeSection, DomSection, DomTarget

Constant Summary collapse

@@template_cache =
{}

Instance Method Summary collapse

Instance Method Details

#insert_anchor_before_end(binding_name) ⇒ Object



16
17
18
# File 'lib/volt/page/targets/base_section.rb', line 16

def insert_anchor_before_end(binding_name)
  fail 'insert_anchor_before_end is not implemented'
end

#removeObject



8
9
10
# File 'lib/volt/page/targets/base_section.rb', line 8

def remove
  fail 'remove is not implemented'
end

#remove_anchorsObject



12
13
14
# File 'lib/volt/page/targets/base_section.rb', line 12

def remove_anchors
  fail 'remove_anchors is not implemented'
end

#set_content_to_template(volt_app, template_name) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/volt/page/targets/base_section.rb', line 24

def set_content_to_template(volt_app, template_name)
  if self.is_a?(DomSection)
    # DomTemplates are an optimization when working with the DOM (as opposed to other targets)
    dom_template = (@@template_cache[template_name] ||= DomTemplate.new(volt_app, template_name))

    set_template(dom_template)
  else
    template = volt_app.templates[template_name]

    if template
      html     = template['html']
      bindings = template['bindings']
    else
      html     = "<div>-- &lt; missing view or tag at #{template_name.inspect}, make sure it's component is included in dependencies.rb &gt; --</div>"
      bindings = {}
    end

    set_content_and_rezero_bindings(html, bindings)
  end
end

#set_templateObject



20
21
22
# File 'lib/volt/page/targets/base_section.rb', line 20

def set_template
  fail 'set_template is not implemented'
end