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_endObject



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

def insert_anchor_before_end
  fail 'not implemented'
end

#removeObject



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

def remove
  fail 'not implemented'
end

#remove_anchorsObject



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

def remove_anchors
  fail 'not implemented'
end

#set_content_to_template(page, template_name) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/volt/page/targets/base_section.rb', line 20

def set_content_to_template(page, template_name)
  if self.is_a?(DomSection)
    dom_template = (@@template_cache[template_name] ||= DomTemplate.new(page, template_name))

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

    if template
      html     = template['html']
      bindings = template['bindings']
    else
      html     = "<div>-- &lt; missing template #{template_name.inspect.gsub('<', '&lt;').gsub('>', '&gt;')} &gt; --</div>"
      bindings = {}
    end

    return set_content_and_rezero_bindings(html, bindings)
  end
end