theme_render_template

Versions
6 – 7
theme_render_template($template_file, $variables)

Render a system default template, which is essentially a PHP template.

Parameters

$template_file The filename of the template to render. Note that this will overwrite anything stored in $variables['template_file'] if using a variable processor hook.

$variables A keyed array of variables that will appear in the output.

Return value

The output generated by the template.

Code

includes/theme.inc, line 1237

<?php
function theme_render_template($template_file, $variables) {
  extract($variables, EXTR_SKIP);               // Extract the variables to a local namespace
  ob_start();                                   // Start output buffering
  include DRUPAL_ROOT . '/' . $template_file;   // Include the template file
  $contents = ob_get_contents();                // Get the contents of the buffer
  ob_end_clean();                               // End buffering and discard
  return $contents;                             // Return the contents
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.