function TwigExtension::getFilters
Same name in other branches
- 9 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFilters()
- 10 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFilters()
- 11.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFilters()
File
-
core/
lib/ Drupal/ Core/ Template/ TwigExtension.php, line 159
Class
- TwigExtension
- A class providing Drupal Twig extensions.
Namespace
Drupal\Core\TemplateCode
public function getFilters() {
return [
// Translation filters.
new \Twig_SimpleFilter('t', 't', [
'is_safe' => [
'html',
],
]),
new \Twig_SimpleFilter('trans', 't', [
'is_safe' => [
'html',
],
]),
// The "raw" filter is not detectable when parsing "trans" tags. To detect
// which prefix must be used for translation (@, !, %), we must clone the
// "raw" filter and give it identifiable names. These filters should only
// be used in "trans" tags.
// @see TwigNodeTrans::compileString()
new \Twig_SimpleFilter('placeholder', [
$this,
'escapePlaceholder',
], [
'is_safe' => [
'html',
],
'needs_environment' => TRUE,
]),
// Replace twig's escape filter with our own.
new \Twig_SimpleFilter('drupal_escape', [
$this,
'escapeFilter',
], [
'needs_environment' => TRUE,
'is_safe_callback' => 'twig_escape_filter_is_safe',
]),
// Implements safe joining.
// @todo Make that the default for |join? Upstream issue:
// https://github.com/fabpot/Twig/issues/1420
new \Twig_SimpleFilter('safe_join', [
$this,
'safeJoin',
], [
'needs_environment' => TRUE,
'is_safe' => [
'html',
],
]),
// Array filters.
new \Twig_SimpleFilter('without', [
$this,
'withoutFilter',
]),
// CSS class and ID filters.
new \Twig_SimpleFilter('clean_class', '\\Drupal\\Component\\Utility\\Html::getClass'),
new \Twig_SimpleFilter('clean_id', '\\Drupal\\Component\\Utility\\Html::getId'),
// This filter will render a renderable array to use the string results.
new \Twig_SimpleFilter('render', [
$this,
'renderVar',
]),
new \Twig_SimpleFilter('format_date', [
$this->dateFormatter,
'format',
]),
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.