Software /
code /
prosody
Changeset
10911:9dc34e1556d9
util.human.io.table: Allow a map callaback per column
This allows e.g. mapping booleans to "yes" or "no", specific number
formatting or generating virtual columns. All while not mutating the
underlying data or creating additional temporary tables.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 04 Jun 2020 21:32:28 +0200 |
parents | 10910:e890b83f08cf |
children | 10915:687273948ec7 |
files | util/human/io.lua |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util/human/io.lua Thu Jun 04 18:40:37 2020 +0200 +++ b/util/human/io.lua Thu Jun 04 21:32:28 2020 +0200 @@ -131,7 +131,7 @@ local output = {}; for i, column in ipairs(col_specs) do local width = widths[i]; - local v = tostring(row[not titles and column.key or i] or ""); + local v = (not titles and column.mapper or tostring)(row[not titles and column.key or i] or "", row); if #v < width then if column.align == "right" then v = padleft(v, width-1).." ";