Sha256: 2c3a6122747676784159efed09d16052c341770c399691e3ee66cd91312699f8

Contents?: true

Size: 705 Bytes

Versions: 2

Compression:

Stored size: 705 Bytes

Contents

require 'volt/page/bindings/base_binding'

class ContentBinding < BaseBinding
  def initialize(target, context, binding_name, getter)
    # puts "new content binding: #{getter}"
    super(target, context, binding_name)

    # Find the source for the content binding
    @value = value_from_getter(getter)

    # Run the initial render
    update

    @changed_listener = @value.on('changed') { update }
  end

  def update
    value = @value.cur.or('')
    
    # Exception values display the exception as a string
    value = value.to_s
    
    # Update the text in this section
    section.text = value
  end

  def remove
    @changed_listener.remove
    @changed_listener = nil

    super
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
volt-0.3.9 lib/volt/page/bindings/content_binding.rb
volt-0.3.8 lib/volt/page/bindings/content_binding.rb