Skip to main content

Interpolation filters

The following filters can be called as part of jinja expressions, for example like this: {{ 1 | string }}.

hash​

Convert the specified value to a hashed string.

Examples:

{{ 'Test client_secret' | hash() }} -> '3032d57a12f76b61a820e47b9a5a0cbb'
{{ 'Test client_secret' | hash('md5') }} -> '3032d57a12f76b61a820e47b9a5a0cbb'
{{ 'Test client_secret' | hash('md5', salt='salt') }} -> '5011a0168579c2d94cbbe1c6ad14327c'

Arguments:

  • hash_type: Valid hash type for converts ('md5' as default value).
  • salt: An additional value to further protect sensitive data.

base64encode​

Convert the specified value to a string in the base64 format.

Examples:

{{ 'Test client_secret' | base64encode }} -> 'VGVzdCBjbGllbnRfc2VjcmV0'

base64decode​

Decodes the specified base64 format value into a common string.

Examples:

{{ 'ZmFrZSByZWZyZXNoX3Rva2VuIHZhbHVl' | base64decode }} -> 'fake refresh_token value'

string​

Converts the specified value to a string.

Examples:

{{ 1 | string }} -> "1"
{{ ["hello", "world" | string }} -> "["hello", "world"]"

Match the input string against a regular expression and return the first match.

Examples:

{{ "goodbye, cruel world" | regex_search("goodbye,\s(.*)$") }} -> "cruel world"

Arguments:

  • regex: The regular expression to search for. It must include a capture group.

regex_replace​

Replace all occurrences in the string that match the provided regex pattern with the specified replacement string.

Examples:

{{ "hello world" | regex_replace("world", "universe") }} -> "hello universe"
{{ "hello-world_foo" | regex_replace("[_-]", " ") }} -> "hello world foo"

Arguments:

  • regex: The regular expression pattern to match against.
  • replacement: The string to replace matched occurrences with.