Skip to content

Commit

Permalink
Convert the table component templates to methods
Browse files Browse the repository at this point in the history
They're all really basic and none contain any logic, there's no real
need to rely on templates.
  • Loading branch information
peteryates committed Dec 30, 2022
1 parent 5d48b5a commit f68a2a5
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 22 deletions.
7 changes: 0 additions & 7 deletions app/components/govuk_component/table_component.html.erb

This file was deleted.

4 changes: 4 additions & 0 deletions app/components/govuk_component/table_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header
build(*(head ? [head, rows] : [rows[0], rows[1..]]), caption_text)
end

def call
tag.table(**html_attributes) { safe_join([caption, head, bodies]) }
end

private

def build(head_data, body_data, caption_text)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def initialize(rows: nil, first_cell_is_header: false, classes: [], html_attribu
build_rows_from_row_data(rows, first_cell_is_header)
end

def call
tag.tbody(**html_attributes) { safe_join(rows) }
end

private

def build_rows_from_row_data(data, first_cell_is_header)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def initialize(rows: nil, classes: [], html_attributes: {})
build_rows_from_row_data(rows)
end

def call
tag.thead(**html_attributes) { safe_join(rows) }
end

private

def build_rows_from_row_data(data)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def self.from_body(*args, **kwargs, &block)
new(*args, parent: 'tbody', **kwargs, &block)
end

def call
tag.tr(**html_attributes) { safe_join(cells) }
end

private

def build_cells_from_cell_data(cell_data)
Expand Down

0 comments on commit f68a2a5

Please sign in to comment.