Software /
code /
prosody
Comparison
util/human/io.lua @ 13040:0cbe400ebab4
util.human.io: Pass the whole column definition to mapper function
I forget why I wanted this, but it may allow doing things like pull
settings from the column, especially when the mapper function is reused
among many columns.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 07 Apr 2023 13:02:20 +0200 |
parent | 13039:9ddb344b9fab |
child | 13044:5bd272095388 |
comparison
equal
deleted
inserted
replaced
13039:9ddb344b9fab | 13040:0cbe400ebab4 |
---|---|
160 local output = {}; | 160 local output = {}; |
161 for i, column in ipairs(col_specs) do | 161 for i, column in ipairs(col_specs) do |
162 local width = widths[i]; | 162 local width = widths[i]; |
163 local v = row[not titles and column.key or i]; | 163 local v = row[not titles and column.key or i]; |
164 if not titles and column.mapper then | 164 if not titles and column.mapper then |
165 v = column.mapper(v, row, width); | 165 v = column.mapper(v, row, width, column); |
166 end | 166 end |
167 if v == nil then | 167 if v == nil then |
168 v = column.default or ""; | 168 v = column.default or ""; |
169 else | 169 else |
170 v = tostring(v); | 170 v = tostring(v); |