Class: CCS::Components::GovUK::Table::Body::HeadCell

Inherits:
Base
  • Object
show all
Defined in:
lib/ccs/components/govuk/table/body/head_cell.rb

Overview

GOV.UK Table Body head cell

The individual table body head cell

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for the table body head cell

{ class: 'govuk-table__header' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(text:, **options) ⇒ HeadCell

Returns a new instance of HeadCell.

Parameters:

  • text (String)

    the text of the cell

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :classes (String)

    additional CSS classes for the cell

  • :attributes (Hash) — default: {}

    any additional attributes that will be added as part of the cell



28
29
30
31
32
33
34
# File 'lib/ccs/components/govuk/table/body/head_cell.rb', line 28

def initialize(text:, **options)
  super(**options)

  @options[:attributes][:scope] = 'row'

  @text = text
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Table Body head cell

Returns:

  • (ActiveSupport::SafeBuffer)


40
41
42
# File 'lib/ccs/components/govuk/table/body/head_cell.rb', line 40

def render
  tag.th(text, **options[:attributes])
end