These filters provide useful general functionality.

default

Returns a default value for any variable with no assigned value (i.e. null).

Code
{{ snippets["Header"] | default: 'My Website' }}
Output
<!-- If a snippet with the name "Header" returns null -->
My Website

file_size

Applied to a number value representing a number of bytes, returns a formatted file size with a unit of appropriate scale.

Optionally, a precision parameter can be passed, to control the number of decimal places in the result. The default precision is 1.

Code
{{ 10000000 | file_size }}
{{ 2050 | file_size: 0 }}
{{ entity.notes.first.filesize | file_size: 2 }}
Output
9.5 MB
2 KB
207.14 KB

has_role

Applied to a user object, returns true if the user belongs to the given role. Returns false if not.

Code
{% assign is_admin = user | has_role: 'Administrators' %}
{% if is_admin %}
User is an administrator.
{% endif %}

liquid

Renders a string as Liquid code. This code will have access to the current Liquid execution context (variables, etc.).

  This filter should be used with caution.

It should generally only be applied to values that are under the exclusive control of Adxstudio Portals content authors, or other users that can be trusted to write Liquid code.

Code
{{ page.adx_copy | liquid }}