[formatter] implement 'M' format specifier

Map a list of objects to a list of values

[
    {"name": "John Doe"      , "age": 42},
    {"name": "Jane Smith"    , "age": 24},
    {"name": "Max Mustermann", "age": null}
]

== :Mname =>

["John Doe", "Jane Smith", "Max Mustermann"]
This commit is contained in:
Mike Fährmann
2025-06-22 15:09:28 +02:00
parent 71461ceaba
commit 2bcc2f2a17
3 changed files with 60 additions and 11 deletions

View File

@@ -266,6 +266,12 @@ Format specifiers can be used for advanced formatting by using the options provi
<td><code>{tags:J - /}</code></td>
<td><code>sun - tree - water</code></td>
</tr>
<tr>
<td><code>M&lt;key&gt;/</code></td>
<td>Maps a list of objects to a list of corresponding values by looking up <code>&lt;key&gt;</code> in each object</td>
<td><code>{users:Mname/}</code></td>
<td><code>["John", "David", "Max"]</code></td>
</tr>
<tr>
<td><code>R&lt;old&gt;/&lt;new&gt;/</code></td>
<td>Replaces all occurrences of <code>&lt;old&gt;</code> with <code>&lt;new&gt;</code> using <a href="https://docs.python.org/3/library/stdtypes.html#str.replace" rel="nofollow"><code>str.replace()</code></a></td>