Sha256: 1feedee0d66e422ebd46fc7d6f3286231e19afbc3b515ecb478c2dfe24d7aee6

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

%table{ class: table_css_classes }
  %thead
    %tr
      - columns.each do |name, options|
        - title = options.delete(:title)
        - if title.nil?
          - if resource_class.respond_to?(:human_attribute_name)
            - title = resource_class.human_attribute_name(name)
          - else
            - title = name
        - if options.has_key?(:sort)
          %td= sort_link(name, title, options[:sort])
        - else
          %td= title
  %tbody
    - collection.each do |resource|
      - tr_options = { class: resource_class.name.underscore }
      - if resource.respond_to?(:model_name)
        - tr_options[:id] = dom_id(resource)
      - else
        - tr_options[:id] = "#{resource.class.name.underscore}-#{resource.object_id}"
      %tr{ tr_options }
        - columns.each do |name, options|
          - td_options = { class: "attribute-#{name}", id: "#{tr_options[:id]}-#{name}"}
          - if options[:block].present?
            %td{ td_options }= options[:block].call(resource)
          - else
            %td{ td_options }= resource.send(name)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails-add_ons-1.3.3 app/views/component/_collection_table.haml
rails-add_ons-1.3.2 app/views/component/_collection_table.haml
rails-add_ons-1.3.1 app/views/component/_collection_table.haml
rails-add_ons-1.3.0 app/views/component/_collection_table.haml
rails-add_ons-1.2.0 app/views/component/_collection_table.haml
rails-add_ons-1.1.0 app/views/component/_collection_table.haml
rails-add_ons-1.0.0 app/views/component/_collection_table.haml
rails-add_ons-0.6.0 app/views/component/_collection_table.haml