Class: ContentBinding
- Inherits:
-
BaseBinding
- Object
- BaseBinding
- ContentBinding
- Defined in:
- lib/volt/page/bindings/content_binding.rb
Instance Attribute Summary
Attributes inherited from BaseBinding
#binding_name, #context, #target
Instance Method Summary collapse
-
#initialize(page, target, context, binding_name, getter) ⇒ ContentBinding
constructor
A new instance of ContentBinding.
- #remove ⇒ Object
- #update ⇒ Object
Methods inherited from BaseBinding
#queue_update, #remove_anchors, #section, #value_from_getter
Constructor Details
#initialize(page, target, context, binding_name, getter) ⇒ ContentBinding
Returns a new instance of ContentBinding.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/volt/page/bindings/content_binding.rb', line 4 def initialize(page, target, context, binding_name, getter) # puts "new content binding: #{getter}" super(page, target, context, binding_name) # Find the source for the content binding @value = value_from_getter(getter) # Run the initial render update if @value.reactive? @changed_listener = @value.on('changed') { update } end end |
Instance Method Details
#remove ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/volt/page/bindings/content_binding.rb', line 30 def remove if @changed_listener @changed_listener.remove @changed_listener = nil end super end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/volt/page/bindings/content_binding.rb', line 19 def update value = @value.cur.or('') # Exception values display the exception as a string value = value.to_s # Update the html in this section # TODO: Move the formatter into another class. section.html = value.gsub("\n", "<br />\n") end |