One solution to the whole templates thing would be to have an apache2 filter that pre-parses the PHP files (much like SSI), and substitutes all of the comments with the appropriate code from a file. This ought to be much faster than having php run through huge strings. It should also be a fairly flexible solution - php code doesn't get messed up by template code, template code doesn't get messed up with php.
Anybody know how to write apache filters?