You are here

public function FilterTwig::process in Twig Input Filter 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Filter/FilterTwig.php \Drupal\twig\Plugin\Filter\FilterTwig::process()
  2. 2.0.x src/Plugin/Filter/FilterTwig.php \Drupal\twig\Plugin\Filter\FilterTwig::process()

Performs the filter processing.

Parameters

string $text: The text string to be filtered.

string $langcode: The language code of the text to be filtered.

Return value

\Drupal\filter\FilterProcessResult The filtered text, wrapped in a FilterProcessResult object, and possibly with associated assets, cacheability metadata and placeholders.

Overrides FilterInterface::process

See also

\Drupal\filter\FilterProcessResult

File

src/Plugin/Filter/FilterTwig.php, line 29
Contains \Drupal\twig\Plugin\Filter\FilterTwig.

Class

FilterTwig
Provides a filter that allows text to be rendered using the Twig engine.

Namespace

Drupal\twig\Plugin\Filter

Code

public function process($text, $langcode) {

  /* @var $twig_service \Drupal\Core\Template\TwigEnvironment */
  $twig_service = \Drupal::service('twig');
  return new FilterProcessResult((string) $twig_service
    ->renderInline($text, [
    'langcode' => $langcode,
  ]));
}