Sha256: a72f69118be21551181d0b0aa6851fe5093b6d8f648611c25891451af15c1863

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 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.gsub('/', '-') }
      - if resource.respond_to?(:model_name)
        - tr_options[:id] = dom_id(resource)
      - else
        - tr_options[:id] = "#{resource.class.name.underscore.gsub('/', '-')}-#{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

5 entries across 5 versions & 1 rubygems

Version Path
rails-add_ons-1.5.2 app/views/component/_collection_table.haml
rails-add_ons-1.5.1 app/views/component/_collection_table.haml
rails-add_ons-1.5.0 app/views/component/_collection_table.haml
rails-add_ons-1.4.1 app/views/component/_collection_table.haml
rails-add_ons-1.4.0 app/views/component/_collection_table.haml