Skip to content

Render table cells that aren't strings with to_s - #12

Merged
marcoroth merged 1 commit into
mainfrom
table-non-string-cells
Nov 18, 2026
Merged

marcoroth merged 1 commit into
mainfrom
table-non-string-cells

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

This pull request updates Table#headers, Table#row, and Table#rows to convert each cell with to_s.

The cells are passed to Go as JSON and decoded into strings. A single number, boolean, nil, or Symbol made the decoding fail, and the table was returned without the new rows, so the whole body went missing without an error:

Lipgloss::Table.new
  .headers(["a", "b", "c"])
  .rows([["1", "2", "3"], ["4", "5", "6"], ["7", "8", 9]])
  .render

Before

╭─┬─┬─╮
│a│b│c│
├─┼─┼─┤
╰─┴─┴─╯

After

╭─┬─┬─╮
│a│b│c│
├─┼─┼─┤
│1│2│3│
│4│5│6│
│7│8│9│
╰─┴─┴─╯

Cells are converted the way Ruby converts them for interpolation, so nil renders as an empty cell, true as true, and :sym as sym. The RBS signatures accept _ToS cells accordingly.

Resolves #9

@marcoroth
marcoroth merged commit 2013661 into main Nov 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passing non-String types to Lipgloss::Table in row data renders empty rows

1 participant