Class: GovukComponent::TableComponent
- Defined in:
- app/components/govuk_component/table_component.rb
Defined Under Namespace
Classes: BodyComponent, CaptionComponent, CellComponent, HeadComponent, RowComponent
Instance Attribute Summary collapse
-
#caption_text ⇒ Object
Returns the value of attribute caption_text.
-
#first_cell_is_header ⇒ Object
Returns the value of attribute first_cell_is_header.
-
#id ⇒ Object
Returns the value of attribute id.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header: false, classes: [], html_attributes: {}) ⇒ TableComponent
constructor
A new instance of TableComponent.
Constructor Details
#initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header: false, classes: [], html_attributes: {}) ⇒ TableComponent
Returns a new instance of TableComponent.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/components/govuk_component/table_component.rb', line 9 def initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header: false, classes: [], html_attributes: {}) @id = id @first_cell_is_header = first_cell_is_header @caption_text = super(classes: classes, html_attributes: html_attributes) # when no rows are passed in it's likely we're taking the slot approach return unless rows.presence # if no head is passed in,use the first row for headers build(*(head ? [head, rows] : [rows[0], rows[1..]]), ) end |
Instance Attribute Details
#caption_text ⇒ Object
Returns the value of attribute caption_text.
7 8 9 |
# File 'app/components/govuk_component/table_component.rb', line 7 def @caption_text end |
#first_cell_is_header ⇒ Object
Returns the value of attribute first_cell_is_header.
7 8 9 |
# File 'app/components/govuk_component/table_component.rb', line 7 def first_cell_is_header @first_cell_is_header end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'app/components/govuk_component/table_component.rb', line 7 def id @id end |