Sha256: cd4a7eb0e1a2b0566b2484d501e4fe896af190cd7b1c43713dd3b461e73b99a7

Contents?: true

Size: 1016 Bytes

Versions: 5

Compression:

Stored size: 1016 Bytes

Contents

module TableHelper
  # Represents an HTML element
  # 
  # == Modifying HTML options
  # 
  # HTML options can normally be specified when creating the element.
  # However, if they need to be modified after the element has been created,
  # you can access the properties like so:
  # 
  #   r = Row.new
  #   r[:style] = 'display: none;'
  # 
  # or for a cell:
  # 
  #   c = Cell.new
  #   c[:style] = 'display: none;'
  class HtmlElement
    include ActionView::Helpers::TagHelper
    
    delegate :[], :[]=, :to => '@html_options'
    
    def initialize(html_options = {}) #:nodoc:
      @html_options = html_options.symbolize_keys
    end
    
    # Generates the html representing this element
    def html
      content_tag(tag_name, content, @html_options)
    end
    
    private
      # The name of the element tag to use (e.g. td, th, tr, etc.)
      def tag_name
        ''
      end
      
      # The content that will be displayed inside of the tag
      def content
        ''
      end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
pluginaweek-table_helper-0.2.1 lib/table_helper/html_element.rb
tangofoxtrot-table_helper-0.2.2 lib/table_helper/html_element.rb
table_helper-0.2.2 lib/table_helper/html_element.rb
table_helper-0.2.1 lib/table_helper/html_element.rb
table_helper-0.2.0 lib/table_helper/html_element.rb