You are here

public function TwigExtension::theme in Components! 8

Callback for theme function in Twig.

Parameters

string $theme: The theme definition key.

array $variables: The variables passed for rendering.

Return value

\Drupal\Component\Render\MarkupInterface The renderer markup.

File

src/Template/TwigExtension.php, line 65

Class

TwigExtension
A class providing components's Twig extensions.

Namespace

Drupal\components\Template

Code

public function theme($theme, array $variables) {
  $render_array = [
    '#theme' => $theme,
  ];
  foreach ($variables as $key => $variable) {
    $render_array['#' . $key] = $variable;
  }
  return $this
    ->render($render_array);
}