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
10
# File 'lib/volt/page/reactive_template.rb', line 4

def initialize(page, context, template_path)
  # puts "New Reactive Template: #{context.inspect} - #{template_path.inspect}"
  @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



30
31
32
# File 'lib/volt/page/reactive_template.rb', line 30

def cur
  @target.to_html
end

#reactive?Boolean

Returns:



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

def reactive?
  true
end

#removeObject



38
39
40
41
42
43
44
# File 'lib/volt/page/reactive_template.rb', line 38

def remove
  @template.remove

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

#updateObject



34
35
36
# File 'lib/volt/page/reactive_template.rb', line 34

def update
  trigger!('changed')
end