Sha256: 9444290b7697f2e59ad8cf2e9da697698c33abc07a06a3477d59bfa08c43b533

Contents?: true

Size: 776 Bytes

Versions: 12

Compression:

Stored size: 776 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

    if @value.reactive?
      @changed_listener = @value.on('changed') { update }
    end
  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
    if @changed_listener
      @changed_listener.remove
      @changed_listener = nil
    end

    super
  end


end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
volt-0.4.12 lib/volt/page/bindings/content_binding.rb
volt-0.4.11 lib/volt/page/bindings/content_binding.rb
volt-0.4.10 lib/volt/page/bindings/content_binding.rb
volt-0.4.9 lib/volt/page/bindings/content_binding.rb
volt-0.4.8 lib/volt/page/bindings/content_binding.rb
volt-0.4.7 lib/volt/page/bindings/content_binding.rb
volt-0.4.5 lib/volt/page/bindings/content_binding.rb
volt-0.4.4 lib/volt/page/bindings/content_binding.rb
volt-0.4.3 lib/volt/page/bindings/content_binding.rb
volt-0.4.2 lib/volt/page/bindings/content_binding.rb
volt-0.4.1 lib/volt/page/bindings/content_binding.rb
volt-0.4.0 lib/volt/page/bindings/content_binding.rb