Created
May 11, 2023 14:08
-
-
Save thejeffreystone/03707f2a8ce0d1eceb3023c8c3109bc0 to your computer and use it in GitHub Desktop.
Useful Jinja Filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For more on these and more visit: https://ttl255.com/jinja2-tutorial-part-4-template-filters/ | |
# Covert Previous value to integter | |
| int | |
# Convert previous value to a decimal number, | |
# Replace 0 with number of decimals to include | |
| float(0) | |
# Round value to a specific decimal | |
| round(1) | |
# Set a default value | |
| default(0) | |
#OR include with round | |
| round(0, default=0) | |
# Count the number of distinct entities in previous value | |
| count | |
# List all the entities in the prvious value | |
| list | |
# pick a previous value by random | |
| random | |
# Replace some in the previous value | |
| replace(":", "") | |
# Filter to just a specific attribute | |
| map(attribute='entity_id') | |
# select entities with a specitifc attribute value | |
| selectattr('state', 'eq', 'unavailable') | |
# select entities with a specitifc attribute value | |
| rejectattr('state', 'eq', 'unavailable') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment