Class: 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



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

def insert_anchor_before_end
  raise "not implemented"
end

#removeObject



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

def remove
  raise "not implemented"
end

#remove_anchorsObject



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

def remove_anchors
  raise "not implemented"
end

#set_content_to_template(page, template_name) ⇒ Object



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

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