Sha256: 0b4062b385cf0a50a402b961aedd8ff6f931fa715ab3767f99f0cd398255772e

Contents?: true

Size: 916 Bytes

Versions: 26

Compression:

Stored size: 916 Bytes

Contents

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

require 'volt/page/targets/base_section'

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

    return 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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
volt-0.8.14 lib/volt/page/targets/attribute_section.rb
volt-0.8.13 lib/volt/page/targets/attribute_section.rb
volt-0.8.11 lib/volt/page/targets/attribute_section.rb
volt-0.8.10 lib/volt/page/targets/attribute_section.rb
volt-0.8.9 lib/volt/page/targets/attribute_section.rb
volt-0.8.8 lib/volt/page/targets/attribute_section.rb
volt-0.8.7 lib/volt/page/targets/attribute_section.rb
volt-0.8.6 lib/volt/page/targets/attribute_section.rb
volt-0.8.5 lib/volt/page/targets/attribute_section.rb
volt-0.8.4 lib/volt/page/targets/attribute_section.rb
volt-0.8.3 lib/volt/page/targets/attribute_section.rb
volt-0.8.2 lib/volt/page/targets/attribute_section.rb
volt-0.8.1 lib/volt/page/targets/attribute_section.rb
volt-0.8.0 lib/volt/page/targets/attribute_section.rb
volt-0.7.23 lib/volt/page/targets/attribute_section.rb
volt-0.7.22 lib/volt/page/targets/attribute_section.rb
volt-0.7.21 lib/volt/page/targets/attribute_section.rb
volt-0.7.20 lib/volt/page/targets/attribute_section.rb
volt-0.7.19 lib/volt/page/targets/attribute_section.rb
volt-0.7.18 lib/volt/page/targets/attribute_section.rb