| 1 |
# Template filters |
| 2 |
|
| 3 |
Besides [Jinja2 builtin filters](https://jinja.palletsprojects.com/en/2.11.x/templates/#builtin-filters), |
| 4 |
custom user-defined filter functions can be loaded using the config entry `filter_file`: |
| 5 |
|
| 6 |
Example: |
| 7 |
|
| 8 |
The config file: |
| 9 |
```yaml |
| 10 |
config: |
| 11 |
filter_file: |
| 12 |
- /tmp/myfilter_file.py |
| 13 |
``` |
| 14 |
|
| 15 |
The python filter under `/tmp/myfilter_file.py`: |
| 16 |
```python |
| 17 |
def myfilter(arg1): |
| 18 |
return str(int(arg1) - 10) |
| 19 |
``` |
| 20 |
|
| 21 |
The dotfile content: |
| 22 |
``` |
| 23 |
{{@@ "13" | myfilter() @@}} |
| 24 |
``` |
| 25 |
|
| 26 |
For more information on how to create filters, |
| 27 |
see [the Jinja2 official docs](https://jinja.palletsprojects.com/en/2.11.x/api/#writing-filters). |