Sha256: d65a918bcfc1312e3b4d89e5281da1ee63fe0f8a53a270fe573405f1a329ac16

Contents?: true

Size: 701 Bytes

Versions: 13

Compression:

Stored size: 701 Bytes

Contents

require 'volt/templates/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

13 entries across 13 versions & 1 rubygems

Version Path
volt-0.3.7 lib/volt/templates/content_binding.rb
volt-0.3.6 lib/volt/templates/content_binding.rb
volt-0.3.5 lib/volt/templates/content_binding.rb
volt-0.3.4 lib/volt/templates/content_binding.rb
volt-0.3.3 lib/volt/templates/content_binding.rb
volt-0.3.2 lib/volt/templates/content_binding.rb
volt-0.3.1 lib/volt/templates/content_binding.rb
volt-0.3.0 lib/volt/templates/content_binding.rb
volt-0.2.9 lib/volt/templates/content_binding.rb
volt-0.2.7 lib/volt/templates/content_binding.rb
volt-0.2.5 lib/volt/templates/content_binding.rb
volt-0.2.4 lib/volt/templates/content_binding.rb
volt-0.2.3 lib/volt/templates/content_binding.rb