6 theme.inc theme_render_template($template_file, $variables)
7 theme.inc theme_render_template($template_file, $variables)

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


$template_file: The filename of the template to render.

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

Return value

The output generated by the template.

1 string reference to 'theme_render_template'
theme in includes/theme.inc
Generates themed output.


includes/theme.inc, line 1517
The theme system, which controls the output of Drupal.


function theme_render_template($template_file, $variables) {
  // Extract the variables to a local namespace
  extract($variables, EXTR_SKIP);

  // Start output buffering

  // Include the template file
  include DRUPAL_ROOT . '/' . $template_file;

  // End buffering and return its contents
  return ob_get_clean();


I'm just wondering, as I haven't tried it, but maybe is possible to call this function directly with the theme function:

= array('template_file' => 'path/to/template', 'variables' => $template_vars);
theme('render_template', $variables);

If it's possible, it will be possible to render templates without going through all the preprocess and other hooks that you find when you do theme('theme function that uses the template');

Anyways, as I said, this is a theory, as I haven't tried it. And I'm not saying that is a good idea neither, as it breaks every possible way to alter it. It's just interesting :)