Jinja function list (filters and descriptions)
Table of Contents
| Function Name | Helper Text/Descriptions | Filter & Arguments | When to use |
|---|---|---|---|
| mapvalue | Will execute a VLookup using the map provided. DefaultValue will be piped value if not provided. | {{ some_value | mapvalue('MapName', 'DefaultValue') }} | |
| strptime_to_timestamp | Filter for formatting time. Pipe a a datestring into this. Accepts an argument for the format you're passing the datestring in as. | {{ __scheduled_at | strptime_to_timestamp("%m/%d/%Y") }} | |
| strftime | Transforms a timestamp into a string based on Unix Timestamp | {{key_value | strftime('%H:%M', 'US/Arizona')}} | |
| strptime | Filter for formatting time. to a specific timestring from a UTC timestamp and convert to a specific timezone. | {{ key_value | strptime("%m/%d/%Y", __calendar_tz) }} | |
| unidecode | Decodes unicode values like hellö -> hello | {{key_value|unidecode}} | |
| get_base64_resume_content | {{__long_id|get_base64_resume_content}} | ||
| get_resume_filename | {{__long_id|get_resume_filename}} | ||
| regex_replace | RegExr is a useful site for creating and testing regular expressions | {{ key_value | regex_replace('[^a-zA-Z]', '') }} | |
| initiated_by_email |
Gets email of user who moved candidates to the candidate journey status that's passed as an argument. candidate_journey_status format should be as follows: “<StageName>: <StatusName>" |
{{ __long_id | initiated_by_email(candidate_journey_status) }} e.g. {{__long_id|initiated_by_email("Stage Name: Status Name")}} |
|
| abs() | Return the absolute value of the argument | ||
| batch() | A filter that batches items. It works like slice just the other way round. It returns a list of lists with the given number of items contained. If you provide a second parameter this is used to fill up missing items. | ||
| capitalize() | Capitalize a value. The first character will be uppercase, all others lowercase. | ||
| center() | Centers the value in a field of a given width | ||
| default() | Returns the value if defined, if blank will return the ‘default’ argument. | {{ my_variable|default('my_variable is not defined') }} | |
| escape() |
Convert the characters &, <, >, ‘, and ” in string s to HTML-safe sequences. Allows for these illegal XML characters to be sent as part of the integration.
|
{{__job_loc_name | escape}} | |
| first() | Return the first item of an argument or sequence. | {{ first_name | first }} | |
| last( ) | Return the last item in an argument or sequence | {{ first_name | last }} | |
| lower() | Converts all letter in an argument to be lowercase. | {{ job_loc_name | lower }} | |
| upper() | Converts all letter in an argument to be uppercase. | {{ job_loc_name | upper }} | |
| map() | Accepts a list/sequence, and will perform a defined action on every item within that list. | ||
| max() | Return the largest item from the sequence. | {{ assessment_score | max }} | |
| min() | Return the smallest item from the sequence. | {{ assessment_score | min }} | |
| pprint() | |||
| random() | Return a random item from the sequence. | {{username}}{{ [1,2,3,4,5,6,7,8,9,0] | random}} | |
| reject() | Filters a sequence of objects by applying a test to each object, and rejecting the objects with the test succeeding. | ||
| rejectattr() |
Filters a sequence of objects by applying a test to the specified attribute of each object, and rejecting the objects with the test succeeding. Note: If no test is specified, the attribute’s value will be evaluated as a boolean. |
||
| replace() | Return a copy of the list with all occurrences of a substring replaced with a defined new value. The first argument is the value that should be replaced, the second is the replacement string. If the optional third argument count is given, only the first count occurrences are replaced: | ||
| reverse() | Reverse the object or return an iterator that iterates over it the other way round | ||
| round() |
Round the number to a given decimal. The first parameter specifies the precision (default is 0), the second the rounding method: 'common' rounds either up or down 'ceil' always rounds up 'floor' always rounds down |
{{ pay_rate | round(2) }} | |
| safe() | Mark the value as safe which means that in an environment with automatic escaping enabled this variable will not be escaped. | {{ email | safe }} | |
| select() | Filters a sequence of objects by applying a test to each object, and only selecting the objects with the test succeeding. | ||
| selectattr() | Filters a sequence of objects by applying a test to the specified attribute of each object, and only selecting the objects with the test succeeding. | ||
| slice() | Slice an iterator and return a list of lists containing those items | ||
| sort() | ???? | ||
| split() |
Splits Attribute based on defined separator e.g. {% set names = full_name.split(' ') %} That can then be referenced by index {{names[0]}} |
{% set names = full_name.split(' ') %} | |
| string() | Makes a string unicode if it isn’t already. That way a markup string is not converted back to unicode. | ||
| striptags() | Strip SGML/XML tags and replace adjacent whitespace by one space. | ||
| sum() | Returns the sum of a sequence of numbers plus the value of parameter ‘start’ (which defaults to 0). When the sequence is empty it returns start. | ||
| title() | Return a titlecased version of the value. I.e. words will start with uppercase letters, all remaining characters are lowercase. | ||
| tojson() | Dumps a structure to JSON so that it’s safe to use in <script> tags. It accepts the same arguments and returns a JSON string. | ||
| trim() | Strip leading and trailing characters, by default whitespace | {{middle_name|trim}} | |
| truncate() | Return a truncated copy of the string which only contains a predefined number of characters, dropping the remaining characters after that character limit. | {{first_name|truncate(30, True, '')}} |
Example: {{first_name|truncate(30, True, '')}} Would return just the first 30 characters of the first_name value |
| unique() | Returns a list of unique items from the given sequence | ||
| urlencode() |
URL Encodes the given attribute. e.g. https://stg.paradox.ai/candidates/all-candidates?selected=123456789 becomes: https%3A//stg.paradox.ai/candidates/all-candidates%3Fselected%3D123456789 |
{{some_attribute|urlencode()}} | |
| urlize() | |||
| wordcount() | |||
| wordwrap() | |||
| xmlattr() | |||
|
{{ key_name | int }}
|
int | Convert a string value to an integer in the payload | |
| parse_json | {{test_attribute | parse_json | getattr("city")}} | json object | Converts a string to ‘read-able’ json, which can then be acted upon. |
| format | {{ '%.2f' | format(adjustedPayrate) }} | int | Returns the number with two decimal places including zero (example: 15.00) |
Complex examples
Using Split and a For Loop with an IF condition.
I have an attribute being stored as “value1 and value2”, due to a multiple choice list select question in conversation builder. I need to parse this out, and pass each value individually into a payload for a repeatable element. Going this route means I don’t have to worry about how many options are potentially selected.
My initial value in the “tl_languages” attribute value is “English and Spanish.”
Using
{% set languages = tl_languages.split(' and ') %}
{%- if languages -%}
{% for languages in languages %}
{
"value":"{{languages|lower}}"
}
{%- if not loop.last -%}
,
{% endif %}
{% endfor %}
{% endif %}
Results in:
{
"value":"english"
},
{
"value":"spanish"
}