Sha256: c56dd7dcbf357ad1a29eed178adb1103e6c697a3a5fc28cc6b49c476cb91efb7

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

:ruby
  tr_prefix = if resource.respond_to?(:to_key)
    dom_id(resource)
  else
    "#{resource.class.name.underscore.gsub('/', '-')}-#{resource.object_id}"
  end
%table{ class: table_css_classes, id: "#{tr_prefix}-resource-table" }
  - rows.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
    - elsif title === false
      - title = nil
    %tr{ class: "attribute-#{name}", id: "#{tr_prefix}-#{name}"}
      - if resource_class.respond_to? :human_attribute_name
        %th{ class: 'attribute-name' }
          = title
      - else
        %th{ class: 'attribute-name' }
          = name
      - if options[:block].present?
        %td{ class: 'attribute-value' }
          = options[:block].call(resource)
      - else
        %td{ class: 'attribute-value' }
          = render partial: "rao/component/table/body_cells/#{options[:render_as]}", locals: { resource: resource, name: name, options: options }

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rao-component-0.0.52.pre app/views/rao/component/_resource_table.html.haml
rao-component-0.0.51.pre app/views/rao/component/_resource_table.html.haml
rao-component-0.0.50.pre app/views/rao/component/_resource_table.html.haml