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
Attributes included from GovukComponent::Traits::CustomHtmlAttributes
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.
Methods included from GovukComponent::Traits::CustomClasses
Methods included from Govuk::Components::Helpers::CssUtilities
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.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/components/govuk_component/table_component.rb', line 8 def initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header: false, classes: [], html_attributes: {}) super(classes: classes, html_attributes: html_attributes) @id = id @first_cell_is_header = first_cell_is_header @caption_text = caption # 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..]]), caption_text) end |
Instance Attribute Details
#caption_text ⇒ Object
Returns the value of attribute caption_text.
6 7 8 |
# File 'app/components/govuk_component/table_component.rb', line 6 def caption_text @caption_text end |
#first_cell_is_header ⇒ Object
Returns the value of attribute first_cell_is_header.
6 7 8 |
# File 'app/components/govuk_component/table_component.rb', line 6 def first_cell_is_header @first_cell_is_header end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'app/components/govuk_component/table_component.rb', line 6 def id @id end |