function hook_render_template in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Render/theme.api.php \hook_render_template()
Render a template using the theme engine.
Parameters
string $template_file: The path (relative to the Drupal root directory) to the template to be rendered including its extension in the format 'path/to/TEMPLATE_NAME.EXT'.
array $variables: A keyed array of variables that are available for composing the output. The theme engine is responsible for passing all the variables to the template. Depending on the code in the template, all or just a subset of the variables might be used in the template.
Return value
string The output generated from the template. In most cases this will be a string containing HTML markup.
Related topics
2 functions implement hook_render_template()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- nyan_cat_render_template in core/
modules/ system/ tests/ themes/ engines/ nyan_cat/ nyan_cat.engine - Implements hook_render_template().
- twig_render_template in core/
themes/ engines/ twig/ twig.engine - Implements hook_render_template().
File
- core/
lib/ Drupal/ Core/ Render/ theme.api.php, line 742 - Hooks and documentation related to the theme and render system.
Code
function hook_render_template($template_file, $variables) {
$twig_service = \Drupal::service('twig');
return $twig_service
->loadTemplate($template_file)
->render($variables);
}