nyan_cat.engine
Same filename in other branches
Handles integration of Nyan cat templates because we love kittens.
File
-
modules/
simpletest/ tests/ themes/ engines/ nyan_cat/ nyan_cat.engine
View source
<?php
/**
* @file
* Handles integration of Nyan cat templates because we love kittens.
*/
/**
* Includes .theme file from themes.
*/
function nyan_cat_init($template) {
$file = dirname($template->filename) . '/template.theme';
if (file_exists($file)) {
include_once DRUPAL_ROOT . '/' . $file;
}
}
/**
* Implements hook_theme().
*/
function nyan_cat_theme($existing, $type, $theme, $path) {
$templates = drupal_find_theme_functions($existing, array(
$theme,
));
$templates += drupal_find_theme_templates($existing, '.nyan-cat.html', $path);
return $templates;
}
/**
* Implements hook_extension().
*/
function nyan_cat_extension() {
return '.nyan-cat.html';
}
/**
* Implements hook_render_template().
*
* @param string $template_file
* The filename of the template to render.
* @param mixed[] $variables
* A keyed array of variables that will appear in the output.
*
* @return string
* The output generated by the 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 (strpos($output, '9' . $key) !== FALSE) {
$output = str_replace('9' . $key, $variable, $output);
}
}
return $output;
}
Functions
Title | Deprecated | Summary |
---|---|---|
nyan_cat_extension | Implements hook_extension(). | |
nyan_cat_init | Includes .theme file from themes. | |
nyan_cat_render_template | Implements hook_render_template(). | |
nyan_cat_theme | Implements hook_theme(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.