Sha256: eed4be0390ce89c2fc2bef6eb0f356fdcd2f807bbef2ded3ea1243403ec6b212

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 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 }
              - if options[:label_method].present?
                = resource.send(name).send(options[:label_method])
              - else
                = resource.send(name)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-add_ons-2.0.2 app/views/component/_collection_table.haml
rails-add_ons-2.0.1 app/views/component/_collection_table.haml
rails-add_ons-2.0.0 app/views/component/_collection_table.haml