function nyan_cat_render_template in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine \nyan_cat_render_template()
- 7 modules/simpletest/tests/themes/engines/nyan_cat/nyan_cat.engine \nyan_cat_render_template()
- 9 core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine \nyan_cat_render_template()
Implements hook_render_template().
Parameters
string $template_file: The filename of the template to render.
mixed[] $variables: A keyed array of variables that will appear in the output.
Return value
string The output generated by the template.
File
- core/
modules/ system/ tests/ themes/ engines/ nyan_cat/ nyan_cat.engine, line 35 - Handles integration of Nyan cat templates because we love kittens.
Code
function nyan_cat_render_template($template_file, $variables) {
$output = str_replace('div', 'nyancat', file_get_contents(\Drupal::root() . '/' . $template_file));
foreach ($variables as $key => $variable) {
if (strpos($output, '9' . $key) !== FALSE) {
$output = str_replace('9' . $key, theme_render_and_autoescape($variable), $output);
}
}
return $output;
}