Filters

<- Back to Liquid API

Filters are simple methods that modify the output of numbers, strings, variables and objects. They are placed within an output tag {{ }} and are denoted by a pipe character |.

The Liquid markup language comes with a set of filters that you can find here here.

In addition to those, Thinkific's Liquid variation adds a couple more which are described below.

String filtersLink

hmac_sha256Link

Converts a string into a SHA-256 hash using a hash message authentication code (HMAC). Pass the secret key for the message as a parameter to the filter.

Input:

{% assign my_secret_string = "ThinkificIsAwesome!" | hmac_sha256: "secret_key" %}
My encoded string is: {{ my_secret_string }}

Output:

My encoded string is: 69d5baaea25489e80c530bd44624b78e2b98512b2ed40dcb7e69a52b5f4c397a

app_hmac_sha256Link

This filter is only available inside a App Section. It works exactly like the hmac_sha256 filter, but instead of requiring a secret, it automatically uses the App's Client Secret as the secret key.

Input:

{% assign my_secret_string = "ThinkificIsAwesome!" %}
My encoded string is: {{ my_secret_string }}

Output:

My encoded string is: 69d5baaea25489e80c530bd44624b78e2b98512b2ed40dcb7e69a52b5f4c397a

This enable apps to send information from the app sections through AJAX requests reliably. Here follows an example of that:

<script>
  {% capture params %}id={{site.current_user.id}}&timestamp=123456789&test=true{% endcapture %}
  var params = '{{ params }}';
  var code = '{{ params | app_hmac_sha256 }}';
  fetch(`https://example.com/action?${params}&code=${code}`)
    .then(response => response.json())
    .then(data => console.log(data));
</script>