Sha256: 505266affb8a3fd9fdeefc3eab0c3ca7ca5d9e6f5c2c25e078eb56a6ddd0b8c1

Contents?: true

Size: 789 Bytes

Versions: 6

Compression:

Stored size: 789 Bytes

Contents

module Aureus
  module Components
    class Listing < Renderable
      def initialize
        @entries = Array.new
        yield(self)
      end

      def entry(head, body = nil, &block)
        init_haml_helpers
        if block_given?
          @entries << ListingEntry.new(head, capture_haml(&block))
        else
          @entries << ListingEntry.new(head, body)
        end
      end

      def render
        content_tag 'table', compact_render(*@entries), class: 'aureus-simple-table'
      end
    end

    class ListingEntry < Renderable
      def initialize(head, body)
        @head = head
        @body = body
      end

      def render
        content_tag 'tr' do
          compact content_tag('th', @head), content_tag('td', @body)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aureus-3.0.5 lib/aureus/components/listing.rb
aureus-3.0.4 lib/aureus/components/listing.rb
aureus-3.0.3 lib/aureus/components/listing.rb
aureus-3.0.2 lib/aureus/components/listing.rb
aureus-3.0.1 lib/aureus/components/listing.rb
aureus-3.0.0 lib/aureus/components/listing.rb