FilterTwig.php in Twig Input Filter 2.0.x
File
src/Plugin/Filter/FilterTwig.php
View source
<?php
namespace Drupal\twig\Plugin\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
class FilterTwig extends FilterBase {
public function process($text, $langcode) {
$twig_service = \Drupal::service('twig');
return new FilterProcessResult((string) $twig_service
->renderInline($text, [
'langcode' => $langcode,
]));
}
public function tips($long = FALSE, $context = []) {
return $this
->t('Use the Twig templating engine to render the text. See <a href=":url">@url</a> for more information.', [
':url' => 'http://twig.sensiolabs.org/documentation',
'@url' => 'http://twig.sensiolabs.org/documentation',
]);
}
}
Classes
Name |
Description |
FilterTwig |
Provides a filter that allows text to be rendered using the Twig engine. |