Same filename and directory in other branches
  1. 8.9.x core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
  2. 9 core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine

Handles integration of Nyan cat templates because we love kittens.

File

core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
View source
<?php

/**
 * @file
 * Handles integration of Nyan cat templates because we love kittens.
 */
use Drupal\Component\Utility\Html;

/**
 * Implements hook_theme().
 */
function nyan_cat_theme($existing, $type, $theme, $path) {
  return drupal_find_theme_templates($existing, '.nyan-cat.html', $path);
}

/**
 * Implements hook_extension().
 */
function nyan_cat_extension() {
  return '.nyan-cat.html';
}

/**
 * Implements hook_render_template().
 */
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;
}

Functions