Filters

Filters transform template variables before they are rendered.

Binaries
first last length to_binary
Booleans
yesno
Dates
add_hour add_day add_month add_week add_year date date_range datediff eq_day in_future in_past ne_day sub_hour sub_day sub_month sub_week sub_year timesince…
Encryption
md5 sha1
Character escaping
brlinebreaks escape escape_check escape_ical escape_link escapejs escapejson escapexml fix_ampersands force_escape linebreaksbr slugify unescape urlencode…
Forms
pickle
HTML
show_media striptags truncate_html sanitize_html sanitize_url urlize embedded_media without_embedded_media
Lists
after before chunk exclude filter first flatten_value group_by index_of is_list join last length make_list member nthtail random randomize range reversed slice…
Mailing list
inject_recipientdetails mailinglist_recipient_key_decode
Menu
menu_flat menu_ids menu_is_visible menu_expand menu_rsc menu_subtree menu_trail
Miscellaneous
gravatar_code ip2country ip2geo is_letsencrypt_valid_hostname format_dispatch_controller_option format_dispatch_path_element
Numbers
filesizeformat format_duration format_integer format_number format_price is_even is_number max min minmax rand round round_significant to_integer…
Regular Expressions
match replace
Resource lists
group_firstchar group_title_firstchar is_a is_not_a is_visible media_for_language
Resources
admin_merge_diff content_type_label content_type_urls summary temporary_rsc
Strings
append capfirst center filesizeformat format_duration format_integer format_number format_price insert is_valid_email length ljust log_format_stack lower…
Survey
survey_answer_split survey_any_correct_answer survey_any_wrong_answer survey_as_pages survey_is_stop survey_is_submit survey_prepare_matching…
Translation
is_rtl language language_dir language_sort media_for_language set_url_language trans_languages trans_filter_filled translation
Tuples
element
URLs and links
is_site_url url url_abs sanitize_url is_letsencrypt_valid_hostname urlize escape_link urlencode urldecode parse_url
Variables
as_atom default if if_undefined is_defined is_undefined make_value pprint to_binary to_integer to_json

Controllers Reference Tags

All Filters

add_day

Adds a day to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

add_hour

Adds an hour to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

add_month

Adds a month to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

add_week

Adds a week to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

add_year

Adds a year to a date. The value must be of the form {{Y,M,D},{H,I,S}} .

after

Return the first element after another element in a list. For example:

append

Appends the argument to the value.

as_atom

Convert a value to an Erlang atom.

before

Return the first element before another element in a list. For example:

brlinebreaks

Translate HTML <br/> elements into ASCII newlines ( \n ).

capfirst

Converts the first character of the value to uppercase.

center

Centers the value in a field of a certain width using spaces.

chunk

This filter splits a list in shorter lists. It splits an array in sub-arrays of at most a given length. This is useful…

date

Formats a date or datetime according to the format specified in the argument.

datediff

Calculate the difference between two dates, returning a single part of that difference.

date_range

Show a date range.

default

Provide an alternative value in case a value has a falsy value (0, false , undefined or empty string).

element

Select an element from a tuple or list of tuples.

embedded_media

Fetch media ids that are embedded in the body , body_extra and text blocks of your page.

eq_day

Tests if the value is a date and equal to the argument. The value and the argument must be a tuple of the format {Y,M

escape

HTML escape a text. Escapes all reserved HTML characters in the value. Escaped strings are safe to be displayed in a…

escape_check

Ensures thant an HTML escaped value is properly escaped.

escape_ical

Escape the value according to the RFC2445 rules.

escapejs

Escapes the value for insertion in JavaScript output.

escapejson

Escapes the value for insertion in JSON output.

escape_link

Convert any URLs in a plaintext into HTML links, with adding the rel="nofollow" attribute, and replaces all newlines…

escapexml

Escape the value for insertion in xml output.

exclude

Filters a list on the value of a property, either on absence or inequality.

filesizeformat

This filter formats a numeric value as KB, MB etc. This filter can be used to display a number of bytes in a human…

filter

Filters a list on the value of a property, either on presence or equality.

first

Returns the first character or element.

fix_ampersands

Replaces ampersands in the value with “&amp;” entities.

flatten_value

Flatten a list to a comma separated string.

force_escape

HTML escapes a text.

format_dispatch_controller_option

Format dispatch controller options.

format_dispatch_path_element

Format dispatch path element so variables will be more visible.

format_duration

Show a duration in hours, minutes and seconds.

format_integer

Show an integer value.

format_number

Show an integer or float.

format_price

Show a price with decimals.

gravatar_code

Calculate the gravatar code for an e-mail address:

group_by

Groups items of a list by a property.

group_firstchar

Group a list of sorted resource ids on their first letter of the title or another rsc property. After grouping, it…

group_title_firstchar

Similar to group_firstchar, but always uses the title column from the rsc table.

if

Selects an argument depending on a condition.

if_undefined

Tests whether a value is undefined, returning the given argument.

index_of

Returns the index of the first occurrence of the item in the given list.

in_future

Tests if a date is in the future.

inject_recipientdetails

Adds recipient query string details to hyperlinks.

in_past

Tests if a date is in the past.

insert

Prepends the argument in front of the value.

ip2country

Maps an IP address to a country using the MaxMind GeoIP2 database.

ip2geo

Maps an IP address to information about that country.

is_a

Filter a list of resource ids on category, or test if a single resource id belongs to a category.

is_defined

Tests if a value is defined.

is_even

Test if an integer value is even:

is_letsencrypt_valid_hostname

Test if a hostname can be used for a Let’s Encrypt certificate.

is_list

Test if a value is a list:

is_not_a

is_not_a mirrors is_a. It is particularly useful when iterating over a category and excluding members of a sub-category…

is_number

Test if a value is a number (integer or floating point):

is_rtl

Check if the given language is a rtl or ltr language.

is_site_url

Test if the given URL is a url for the current site.

is_undefined

Tests if a value is undefined.

is_visible

Filter a list of resource ids so that only the visible ids remain.

join

Joins the elements of a list. Joins the elements of the input list together, separated by the argument.

language

Return the language the resource (or translated text) will be displayed in.

language_dir

Return rtl or ltr depening on the direction of the language.

language_sort

Sort a list of language codes or map with languages on their name. Return a list of {Code, LanguageProps} pairs.

last

Returns the last character or element.

length

Returns the length of the value.

linebreaksbr

Translate ASCII newlines ( \n ) into HTML <br /> elements.

ljust

Justifies the value in a field of a certain width to the left, with spaces.

log_format_stack

Escapes and formats a Javascript string with a stack trace to readable HTML.

lower

Translates the value to lower case.

mailinglist_recipient_key_decode

Used on the mailing list subscriptions page where users and recipients can unsubscribe from mailinglists.

make_list

Forces the value to a list.

match

Match a value with a regular expression.

max

Take the maximum of the filter value and its first argument.

md5

Translates a string to a md5 hex value.

media_for_language

Filter a list of media items by their medium_language property, return the best matching with the current or given…

member

Finds a value in a list.

menu_expand

Takes a menu, or a menu resource id, and adds all haspart objects connected to the menu ids.

menu_flat

Flattens the rsc menu structure for use in a template loop.

menu_ids

Returns all resource ids in a menu. Could return invisible and non existing resource ids. The returned ids are a flat…

menu_is_visible

Filters a list of menu items on visibility and existance. Only top-level menu items that are both visible and exist are…

menu_rsc

Return the menu to be displayed with a resource.

menu_subtree

Get the subtree of an id in a menu (if any).

menu_trail

Return a breadcrumb navigation trail for the given id.

min

Take the minimum of the filter value and its first argument.

minmax

Force the given value in the given range.

ne_day

Tests if two dates are not equal.

normalize_email

Normalize an email address, used in the identity management.

nthtail

Fetch the nth tail of a list.

parse_url

Parses an URL (URI) using uri_string:parse/1 .

pickle

Pickle an Erlang value so that it can be safely submitted with a form.