function nyan_cat_render_template

Same name in other branches
  1. 7.x modules/simpletest/tests/themes/engines/nyan_cat/nyan_cat.engine \nyan_cat_render_template()
  2. 9 core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine \nyan_cat_render_template()
  3. 8.9.x core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine \nyan_cat_render_template()
  4. 11.x core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine \nyan_cat_render_template()

Implements hook_render_template().

File

core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine, line 27

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 (str_contains($output, '9' . $key)) {
            $output = str_replace('9' . $key, Html::escape($variable), $output);
        }
    }
    return $output;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.