function twig_render_template

Render twig templates.

This retrieves the Twig_Environment from the Drupal Injection container and renders the template.

Parameters

$template_file: The filename of the template to render.

$variables: A keyed array of variables that will appear in the output.

Return value

The output generated by the template.

File

drupal/core/themes/engines/twig/twig.engine, line 47
Handles integration of Twig templates with the Drupal theme system.

Code

function twig_render_template($template_file, $variables) {
  $variables['_references'] = array();
  return drupal_container()
    ->get('twig')
    ->loadTemplate($template_file)
    ->render($variables);
}