New liquid filters, sending files via API calls

Last edit:

September 20, 2018

In this release notes we will focus on new liquid filters, fixed filter and one new feature.


assign_to_hash_key filter

This filter allows you to add new key-value pairs into existing hash.


{% assign accountants = "Angela,Kevin,Oscar" | split: "," %}
{% assign management = "David,Jan,Michael" | split: "," %}

{% assign company = '{}' | to_hash %}
{% assign company = company | assign_to_hash_key: "name", "Dunder Mifflin" %}
{% assign company = company | assign_to_hash_key: "accountants", accountants %}
{% assign company = company | assign_to_hash_key: "management", management %}
{{ company }}


{"name"=>"Dunder Mifflin", "accountants"=>["Angela", "Kevin", "Oscar"], "management"=>["David", "Jan", "Michael"]}

sanitize filter

This filter allows you to sanitize user input before rendering it and at the same time decide which attributes should not be sanitized.


{% capture link %}
  <a href="javascript:prompt(1)" target="_blank">Link</a>
{% endcapture %}
{{ link | sanitize }} => <a href="">Link</a>
{% assign whitelist_attributes = 'target' | split: '|' %}
{{ link | sanitize: whitelist_attributes }}


<a href="" target="_blank">Link</a>

useragent filter

There was a community request to make it easier to access useragent and parse it, so here it is.

You can access useragent string (as you normally could in the past)

This filter takes useragent string as an input and returns object with parsed data about it.


{{ context.headers.HTTP_USER_AGENT | useragent }}

You can use json filter for readability:

{{ context.headers.HTTP_USER_AGENT | useragent | json }}


random_string filter

This filter was returning string that was longer than expected. Now it returns string of length that you want.


{{ 10 | random_string }} => '6a1e7e2629'
{{ 2 | random_string }} => '8b'


Binary files over API call notifications

You have the possibility to send binary files in API call. This might be useful when integrating your system with external APIs that require additional data from your users, for example photo.

Read guide Sending a Binary File Using an API Call Notification to learn more.


We are always happy to help with any questions you may have.

contact us