How can I parse php code from another file during nodeapi function? I am embedding html and loading javascript onto a page with the nodeapi function.

I use it in this form:

 function first_order_decay_nodeapi(&amp;$node, $op, $a3 = NULL, $a4 = NULL) {
     if($op == 'alter') {
         $path = drupal_get_path('module', 'first_order_decay');
         $path .= '/';
         $code = file_get_contents($path . 'templates/first_order_decay-static.tpl.php', false);
         $code = preg_replace("/[\r\n]*/","",$code);           //make $code one line of text
         $code = preg_replace("/&lt;!--EMBEDREMOVE--&gt;.+&lt;!--EMBEDREMOVE--&gt;/","",$code);  //remove stuff in between these comments. This is stuff I don't want
         $pos = strpos($node-&gt;body, '[FLOT](kinetics1)');   //search node-&gt;body for this command
         if ($pos !== false) {     //insert my html if we found my embed command "[FLOT](kinetics1)"
             $node-&gt;body = substr_replace($node-&gt;body, $code, $pos, strlen('[FLOT](kinetics1)'));
             //add in js
         }
     }
 }


The question is.... How can I parse php into html from $code variable? It seems that because the page is already in the rendering process, Drupal ignores the php. Is there another phase of nodeapi I can use to do this?

Thanks!
As i get you, you need to implement hook_theme and use it, instead parsing php code.

Please, see anwser here: https://stackoverflow.com/questions/12985689/how-to-implement-hook-theme-in-drupal-7