function NyanCatThemeEngine::renderTemplate
File
-
core/
modules/ system/ tests/ modules/ nyan_cat/ src/ NyanCatThemeEngine.php, line 31
Class
- NyanCatThemeEngine
- NYAN NYAN NYAN!
Namespace
Drupal\nyan_catCode
public function renderTemplate(string $template_file, array $variables) : string|MarkupInterface {
$output = str_replace('div', 'nyancat', file_get_contents(\Drupal::root() . '/' . $template_file . '.nyan-cat.html'));
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.