Sha256: 8edcecc41776d4a18097b12652f194dabca98a028b1a696b40367b5660064c97

Contents?: true

Size: 985 Bytes

Versions: 38

Compression:

Stored size: 985 Bytes

Contents

# AttributeSection provides a place to render templates that
# will be placed as text into an attribute.

require 'volt/page/targets/base_section'

module Volt
  class AttributeSection < BaseSection
    def initialize(target, binding_name)
      @target       = target
      @binding_name = binding_name
    end

    def text=(text)
      set_content_and_rezero_bindings(text, {})
    end

    def html=(value)
      set_content_and_rezero_bindings(value, {})
    end

    # Takes in our html and bindings, and rezero's the comment names, and the
    # bindings.  Returns an updated bindings hash
    def set_content_and_rezero_bindings(html, bindings)
      if @binding_name == 'main'
        @target.html = html
      else
        @target.find_by_binding_id(@binding_name).html = html
      end

      bindings
    end

    def remove
      # TODO: is this getting run for no reason?
      node = @target.find_by_binding_id(@binding_name)
      node.remove if node
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
volt-0.9.3.pre1 lib/volt/page/targets/attribute_section.rb
volt-0.9.2 lib/volt/page/targets/attribute_section.rb
volt-0.9.1 lib/volt/page/targets/attribute_section.rb
volt-0.9.1.pre5 lib/volt/page/targets/attribute_section.rb
volt-0.9.1.pre4 lib/volt/page/targets/attribute_section.rb
volt-0.9.1.pre3 lib/volt/page/targets/attribute_section.rb
volt-0.9.1.pre2 lib/volt/page/targets/attribute_section.rb
volt-0.9.1.pre1 lib/volt/page/targets/attribute_section.rb
volt-0.9.0 lib/volt/page/targets/attribute_section.rb
volt-0.9.0.pre7 lib/volt/page/targets/attribute_section.rb
volt-0.9.0.pre6 lib/volt/page/targets/attribute_section.rb
volt-0.9.0.pre5 lib/volt/page/targets/attribute_section.rb
volt-0.9.0.pre4 lib/volt/page/targets/attribute_section.rb
volt-0.9.0.pre3 lib/volt/page/targets/attribute_section.rb
volt-0.9.0.pre2 lib/volt/page/targets/attribute_section.rb
volt-0.9.0.pre1 lib/volt/page/targets/attribute_section.rb
volt-0.8.27.beta9 lib/volt/page/targets/attribute_section.rb
volt-0.8.27.beta8 lib/volt/page/targets/attribute_section.rb
volt-0.8.27.beta7 lib/volt/page/targets/attribute_section.rb
volt-0.8.27.beta6 lib/volt/page/targets/attribute_section.rb