One of the Liquid limitations is the fact that you can't create your own functions when coding. This means a lot of code is being repeated.

DataJet offers simple mechanism for implementing your functions in Liquid and avoiding code duplication across your tasks.

The idea is simple. Each function can be called with a custom filter called apply. This filter will accept function input (anything to the left of the | symbol) and function name (right after colon) in form of a string.

New functions can be added in Settings section of the app.

There are two limitations:

  • recursive functions are not allowed

  • each functions needs to have unique name

Each function have two variables preloaded

  • function_input - whatever was on left side of the | symbol

  • function_output - this will be returned as a result of function execution. Its initial value is empty JSON object.


Let's assume we have simple function called hello_world defined with below code.

{% assign input = function_input %}
{% assign input["foo"] = "bar" %}
{% assign function_output = input %}

Now, you can call this function in hooks code using apply filter:

{% assign fn_input = '{"foo": ""}' | parse %}
{% assign fn_result = fn_input | apply: "hello_world" %}

As a result, value of fn_result will be:

"foo": "bar"