PDFMonkey filters
Array filters
push
Adds an item to an array
{% assign arr = "earth wind" | split: " " %}
{% assign arr = arr | push: "fire" %}
{{arr | to_sentence}}earth, wind and fireslice_by
Slices an array in groups of N elements.
{% assign reindeers = "Dasher Dancer Prancer Vixen Comet Cupid Donner Blitzen Rudolph" | split: " " %}
{% assign reindeerPairs = reindeers | slice_by: 2 %}
{% for reindeerPair in reindeerPairs %}
Pair:
{% for reindeer in reindeerPair %}
- {{reindeer}}
{% endfor %}
{% endfor %}sum
Returns the sum of a numbers array.
Let's say you have this in your data:
to_sentence
Converts the array to a comma-separated sentence where the last element is joined by the connector word.
where_exp
Similar to Liquid's where but accepts an expression.
Let's start with the data:
Date and time filters
in_time_zone
URL filters
ensure_protocol
You might get asset URLs that don’t include any protocol. Sadly our rendering engine doesn’t support this type of URL. For this reason we provide ensure_protocol that will add a protocol as needed:
Number filters
format
The format filter is useful for advanced number formatting. For simpler formatting, prefer with_delimiter.
with_delimiter
For basic number formatting like money for instance, the with_delimiter filter will help you set a thousand delimiter, a decimal separator and the precision.
HTML filters
entities
This filter can be very useful if you have to deal with accented or special characters inside the header or footer. It will convert any non-latin character to its HTML entity.
JSON filters
json
If you need to insert dynamic data in its original JSON format (like we do for charts for instance) the json filter is what you need. Notice it’s returning a string, not the object itself.
parse_json
If you have a value in your payload that contains a JSON string, you can use the parse_json filter to parse it and use it as additional data.
Last updated
Was this helpful?
