Sha256: 3bcb7208952d965a2b349800a841b3a2dee5af3dc2fcea79b88d3619ce08202e

Contents?: true

Size: 648 Bytes

Versions: 2

Compression:

Stored size: 648 Bytes

Contents

# encoding: UTF-8

module DryCrud
  module Table
    # Helper class to store column information.
    class Col < Struct.new(:header, :html_options, :template, :block) #:nodoc:

      delegate :content_tag, :capture, to: :template

      # Runs the Col block for the given entry.
      def content(entry)
        entry.nil? ? '' : capture(entry, &block)
      end

      # Renders the header cell of the Col.
      def html_header
        content_tag(:th, header, html_options)
      end

      # Renders a table cell for the given entry.
      def html_cell(entry)
        content_tag(:td, content(entry), html_options)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry_crud-3.0.0 app/helpers/dry_crud/table/col.rb
dry_crud-2.1.2 app/helpers/dry_crud/table/col.rb