Sha256: 00f4a1388e46ddf80c624f313a22e35898795cca70fcf8b0b08c5bcb148ef31d

Contents?: true

Size: 850 Bytes

Versions: 22

Compression:

Stored size: 850 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 html in this section
    # TODO: Move the formatter into another class.
    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

22 entries across 22 versions & 1 rubygems

Version Path
volt-0.5.18 lib/volt/page/bindings/content_binding.rb
volt-0.5.17 lib/volt/page/bindings/content_binding.rb
volt-0.5.16 lib/volt/page/bindings/content_binding.rb
volt-0.5.15 lib/volt/page/bindings/content_binding.rb
volt-0.5.14 lib/volt/page/bindings/content_binding.rb
volt-0.5.13 lib/volt/page/bindings/content_binding.rb
volt-0.5.12 lib/volt/page/bindings/content_binding.rb
volt-0.5.11 lib/volt/page/bindings/content_binding.rb
volt-0.5.10 lib/volt/page/bindings/content_binding.rb
volt-0.5.9 lib/volt/page/bindings/content_binding.rb
volt-0.5.8 lib/volt/page/bindings/content_binding.rb
volt-0.5.7 lib/volt/page/bindings/content_binding.rb
volt-0.5.6 lib/volt/page/bindings/content_binding.rb
volt-0.5.4 lib/volt/page/bindings/content_binding.rb
volt-0.5.3 lib/volt/page/bindings/content_binding.rb
volt-0.5.2 lib/volt/page/bindings/content_binding.rb
volt-0.5.1 lib/volt/page/bindings/content_binding.rb
volt-0.5.0 lib/volt/page/bindings/content_binding.rb
volt-0.4.18 lib/volt/page/bindings/content_binding.rb
volt-0.4.17 lib/volt/page/bindings/content_binding.rb