Class: ReactiveTemplate

Inherits:
Object show all
Includes:
Events
Defined in:
lib/volt/page/reactive_template.rb

Instance Method Summary collapse

Methods included from Events

#event_chain, #has_listeners?, #listeners, #on, #remove_listener, #trigger!, #trigger_by_scope!, #trigger_for_methods!

Constructor Details

#initialize(page, context, template_path) ⇒ ReactiveTemplate

Returns a new instance of ReactiveTemplate.



4
5
6
7
8
9
# File 'lib/volt/page/reactive_template.rb', line 4

def initialize(page, context, template_path)
  @template_path = template_path
  @target = AttributeTarget.new(nil, nil, self)
  @template = TemplateRenderer.new(page, @target, context, "main", template_path)

end

Instance Method Details

#curObject

Render the template and get the current value



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

def cur
  @target.to_html
end

#reactive?Boolean

Returns:



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

def reactive?
  true
end

#removeObject



24
25
26
27
28
29
30
# File 'lib/volt/page/reactive_template.rb', line 24

def remove
  @template.remove

  @template = nil
  @target = nil
  @template_path = nil
end

#updateObject



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

def update
  trigger!('changed')
end