BSD Helper Functions
In addition to the standard library functions, you have access to the following functions and filters:
Filters
where
whereSpecialized filtering filter for reducing an array of objects by particular matching conditions. This is particularly useful with contribution.contributions.
For example, if you wanted to filter down to just contributions that were not recurring and made online:
{% set contribs = contribution.contributions | where( {'is_online': 1, 'is_recurring': 0} ) %}
It also accepts Mongo-like comparison operators (gt, gte, lt, lte), which are useful for inequality comparisons.
For example, if you wanted to filter down to transactions made in a given date range:
{% set contribs = contribution.contributions | where( {"transaction_dt": {"lte": "2014-01-01 00:00:00", "gt": "2015-01-01 00:00:00"}) %}
sort_by
sort_bySpecialized sorting filter for sorting an array of objects by a particular key's value. This is particularly useful with contribution.contributions, which includes the detailed contribution history data.
{% set example_data = [ {"transaction_amt":100, "transaction_dt": "2014-01-01 00:00:00}, {"transaction_amt":50, "transaction_dt": "2013-01-01 00:00:00}] %}
{{ example_data | sort_by("transaction_dt") | first.transaction_amt }} will return the oldest contribution's amount.
md5
md5Hashes a string using the md5 algorithm. Though it is very difficult to un-hash an md5, it is not considered a secure way to pass highly sensitive data.
{{ recipient.email | md5 }}
base64
base64Encode a string using base64 encoding, which is a reversible encoding format.
{{ recipient.email | base64 }}
This should not be used as a way to encrypt secure data.
Functions
sum
sumCalculate the sum of an array of values.
{% set numbers = [ 1, 4, 10] %}
{{ sum(numbers) }} will be 15.
Updated less than a minute ago
