Twig Filters

A number of Twig filters are defined in W3C\WebsiteTemplatesBundle\Twig\TwigExtension. These filters are:

preg_replace

The preg_replace filter formats a string by performing a preg_replace on it.

Arguments:

markup_attrs

The markup_attrs filter formats a string of XML (or similar well-formed markup language) by adding or replacing attributes to/from its root element.

{{ xml|markup_attrs({
    'aria-hidden': 'true',
    'class': 'icon icon--larger',
    'focusable': 'false',
    'height': '1em',
    'width': '1em'
})|raw }}

Arguments:

avatar

The avatar filter transforms an email address into a URL of the avatar of the W3C user corresponding to this email.

{{ 'foo@bar.com'|avatar('sm')

Arguments:

event_type

The event_type filter transforms an event (represented as an array) into its type as an HTML class.

Arguments:

crosslink_type

The crosslink_type filter transform a Craft section handle into a translatable string reference, useful in crosslink cards which indicate the type of content at the bottom.

Arguments:

date_range

The date_range filter transforms an event (represented as an array) into its formatted start and end dates.

Arguments: