[formatter] add basic 'Jinja2' template support (#1390)

This commit is contained in:
Mike Fährmann
2025-07-16 23:06:35 +02:00
parent cbf930c99c
commit f25c5f4b0c
5 changed files with 77 additions and 7 deletions

View File

@@ -381,15 +381,20 @@ Starting a format string with `\f<Type> ` allows to set a different format strin
</tr>
</thead>
<tbody>
<tr>
<td align="center"><code>E</code></td>
<td>An arbitrary Python expression</td>
<td><code>\fE title.upper().replace(' ', '-')</code></td>
</tr>
<tr>
<td align="center"><code>F</code></td>
<td>An <a href="https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals">f-string</a> literal</td>
<td><code>\fF '{title.strip()}' by {artist.capitalize()}</code></td>
</tr>
<tr>
<td align="center"><code>E</code></td>
<td>An arbitrary Python expression</td>
<td><code>\fE title.upper().replace(' ', '-')</code></td>
<td align="center"><code>J</code></td>
<td>A <a href="https://jinja.palletsprojects.com/">Jinja</a> template</td>
<td><code>\fJ '{{title | trim}}' by {{artist | capitalize}}</code></td>
</tr>
<tr>
<td align="center"><code>T</code></td>
@@ -401,6 +406,11 @@ Starting a format string with `\f<Type> ` allows to set a different format strin
<td>Path to a template file containing an <a href="https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals">f-string</a> literal</td>
<td><code>\fTF ~/.templates/fstr.txt</code></td>
</tr>
<tr>
<td align="center"><code>TJ</code></td>
<td>Path to a template file containing a <a href="https://jinja.palletsprojects.com/">Jinja</a> template</td>
<td><code>\fTF ~/.templates/jinja.txt</code></td>
</tr>
<tr>
<td align="center"><code>M</code></td>
<td>Path or name of a Python module