call template file, pass variables

  1. <?php
  2.  
  3. $text = theme('apply_template', $data);
  4. return $text;
  5.  
  6. function theme_apply_template($data) {
  7.     ob_start();
  8.     include path_to_theme().'/my-block.tpl.php';
  9.     $buffer = ob_get_contents();
  10.     ob_end_clean();
  11.     return $buffer;
  12. }
  13. ?>