The following Liquid filters are custom to the Blueshift platform and can be used in the messaging templates.
- any_contains_filter
- base64_filter
- between_filter
- camel_case_filter
- escape_url_filter
- hash_algo_filter
- image_resize_filter
- json
- less_than_filter
- more_than_filter
- promo_code_filter
- regex_filter
Any contains filter
Check whether a reference string is present in a string or array.
{{ "ola" | any_contains:"a"}}
{% assign people = "fred, john, mary" | split: ", " %}
{{ people | any_contains: "m"}}
Image resize filter
Resize an image.
{{ "https://cdn.getblueshift.com/pictures/8667/content/book_club.jpg" | resize_image: width:320,height:400}}
Hash algorithm filter
Convert a data string into a numeric string output of fixed length. For more information, see https://en.wikipedia.org/wiki/HMAC.
sha1: {{ "lorem ipsum" | sha1 }}
sha256: {{ "lorem ipsum" | sha256 }}
md5: {{ "lorem ipsum" | md5 }}
hmac_sha1: {{ "lorem ipsum" | hmac_sha1: "key1" }}
hmac_sha256: {{ "lorem ipsum" | hmac_sha256: "key1" }}
hmac_sha512: {{ "lorem ipsum" | hmac_sha512: "key1" }}
hmac_md5: {{ "lorem ipsum" | hmac_md5: "key1"}}
base64_encoding: {{ "lorem ipsum" | b64_enc }}
base64_decoding: {{ "bG9yZW0gaXBzdW0=" | b64_dec }}
Shuffle filter
Shuffle items in an array.
{% assign shuffled_products = products | shuffle %}
Time Zone filter
Format ISO 8601 compliant dates into a given timezone. Here's a list of Time Zones this filter supports.
Here are some examples:
{% assign sign_up_date = "Thu Nov 29 2001 14:33:20 UTC" %}
{{ sign_up_date | time_zone: 'Hong Kong' }} => 2001-11-29 22:33:20 +0800
{% assign sign_up_date = "29/11/2001 00:00:00 -0900" %}
{{ sign_up_date | time_zone: 'Hong Kong' }} => 2001-11-29 17:00:00 +0800
The Time Zone filter returns a date and hence the output can be chained with a date filter to format the date value:
{% assign sign_up_date = "Thu Nov 29 2001 14:33:20 UTC" %}
{{ sign_up_date | time_zone: 'Hong Kong' | date: '%d/%m/%Y %H:%M:%S %Z' }} => 29/11/2001 22:33:20 HKT
You can also pass in an hour offset instead of a timezone:
{% assign sign_up_date = "2015-12-01 10:00" %}
{{ sign_up_date | time_zone: -7 | date: '%d-%m-%Y %H:%M' }} => 01-12-2015 03:00
Power Math filter
This filter returns the input to the exponent power.
{{ 2 | pow: 3 }} // 8
{{ 2 | pow: -3 }} // 1/8
{{ -2 | pow: 3 }} // -8
AES 256 Encrypt/Decrypt filter
This filter returns a hex encoded AES 256 ciphertext of the input based on a given key, initialization vector and cipher name.
{{ 'testuser@getblueshift.com' | aes256_encrypt_v2: '9cc25c7879fc94d5a19eeb8e47573b8423becb608a9a4e9d3c25c20aa7e04357','7bdc922b354cc8fa8d3f2910ba7cc411' }}
This outputs the following cipher text:
9be4086dd0f2592273dbe6e0000377ef94ab6aa3573f9344b4abbbbcf47088b7
Cipher text can also be decrypted as follows:
{{ '9be4086dd0f2592273dbe6e0000377ef94ab6aa3573f9344b4abbbbcf47088b7' | aes256_decrypt_v2: '9cc25c7879fc94d5a19eeb8e47573b8423becb608a9a4e9d3c25c20aa7e04357','7bdc922b354cc8fa8d3f2910ba7cc411' }} // testuser@getblueshift.com
The default cipher used is aes-256-cbc, but you can also use aes-256-ecb by passing the cipher name as the 3rd option. Note that the initialization vector is null for ecb mode.
{{ 'hamburger' | aes256_encrypt_v2: '9cc25c7879fc94d5a19eeb8e47573b8423becb608a9a4e9d3c25c20aa7e04357', null, 'aes-256-ecb' }} // 14d60bd236617adc84e23587f46addd1
Money filter
This filter formats numbers as currency. By default it uses the currency configured in your Account Profile.
For example:
{{ 19.99 | money }} // $ 19.99
{{ '19.99' | money }} // $ 19.99
The money filter accepts the following options:
Option |
Default Value |
Sample Values |
use symbol |
true |
true, false |
use space |
true |
true, false |
currency type |
The currency is configurable in the Account Profile |
"USD" "EUR" "GBP" "INR" "SGD" "AED" "SEK" "CHF |
For example, here's a money filter that overrides the default account currency with Indian Rupees and eliminates the space between the currency symbol and number:
Sample Usage with currency and spacing options
{{ 19.99 | money: true,false,'INR' }} // ₹19.99
Use the following variation of the money filter to output without decimals
{{ 1000000 | money_without_trailing_zeros : false }} // 1,000,000
{{ 1000000 | money_without_trailing_zeros }} // $ 1,000,000
Comments
0 comments