# HG changeset patch # User Kim Alvefur # Date 1591299148 -7200 # Node ID 9dc34e1556d96c5a7d2dcc56e463d403148f3074 # Parent e890b83f08cf5d2b50b050331ba51470bde57f2b 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. diff -r e890b83f08cf -r 9dc34e1556d9 util/human/io.lua --- 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).." ";