Class: TemplateRenderer
- Inherits:
-
BaseBinding
- Object
- BaseBinding
- TemplateRenderer
- Defined in:
- lib/volt/page/template_renderer.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Attributes inherited from BaseBinding
Instance Method Summary collapse
-
#initialize(page, target, context, binding_name, template_name) ⇒ TemplateRenderer
constructor
A new instance of TemplateRenderer.
- #remove ⇒ Object
- #remove_anchors ⇒ Object
Methods inherited from BaseBinding
#queue_update, #section, #value_from_getter
Constructor Details
#initialize(page, target, context, binding_name, template_name) ⇒ TemplateRenderer
Returns a new instance of TemplateRenderer.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/volt/page/template_renderer.rb', line 5 def initialize(page, target, context, binding_name, template_name) # puts "new template renderer: #{context.inspect} - #{binding_name.inspect}" super(page, target, context, binding_name) # puts "Template Name: #{template_name}" @template = @page.templates[template_name] @sub_bindings = [] if @template html = @template['html'] bindings = @template['bindings'] else html = "<div>-- < missing template #{template_name.inspect.gsub('<', '<').gsub('>', '>')} > --</div>" bindings = {} end bindings = self.section.set_content_and_rezero_bindings(html, bindings) bindings.each_pair do |id,bindings_for_id| bindings_for_id.each do |binding| @sub_bindings << binding.call(page, target, context, id) end end end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/volt/page/template_renderer.rb', line 4 def context @context end |
Instance Method Details
#remove ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/volt/page/template_renderer.rb', line 30 def remove # puts "Remove Template: #{self} - #{@sub_bindings.inspect}" # Remove all of the sub-bindings # @sub_bindings.each(&:remove) @sub_bindings.each do |binding| # puts "REMOVE: #{binding.inspect}" binding.remove # puts "REMOVED" end @sub_bindings = [] super end |
#remove_anchors ⇒ Object
47 48 49 |
# File 'lib/volt/page/template_renderer.rb', line 47 def remove_anchors section.remove_anchors end |