Sha256: 81eae79b16d0054302304f88d7bc83e7ea780b6c53f0e347f9282decddcea2c6

Contents?: true

Size: 885 Bytes

Versions: 10

Compression:

Stored size: 885 Bytes

Contents

require 'volt/page/bindings/base_binding'

class ContentBinding < BaseBinding
  def initialize(page, target, context, binding_name, 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

  def update
    value = @value.cur.or('')
    if value.reactive?
      puts "GOT CUR: #{value.inspect}"
    end

    # 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.
    dom_section.html = value.gsub("\n", "<br />\n")
  end

  def remove
    if @changed_listener
      @changed_listener.remove
      @changed_listener = nil
    end

    super
  end


end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
volt-0.7.23 lib/volt/page/bindings/content_binding.rb
volt-0.7.22 lib/volt/page/bindings/content_binding.rb
volt-0.7.21 lib/volt/page/bindings/content_binding.rb
volt-0.7.20 lib/volt/page/bindings/content_binding.rb
volt-0.7.19 lib/volt/page/bindings/content_binding.rb
volt-0.7.18 lib/volt/page/bindings/content_binding.rb
volt-0.7.17 lib/volt/page/bindings/content_binding.rb
volt-0.7.16 lib/volt/page/bindings/content_binding.rb
volt-0.7.15 lib/volt/page/bindings/content_binding.rb
volt-0.7.14 lib/volt/page/bindings/content_binding.rb