It's still hack, but unless you use a templating system like Twig you have no choice:
ob_start();
include 'cms/template.php';
$content = ob_get_clean();
echo $content;
ob_start enables output buffering so nothing gets sent to the browser. We then include the file which will execute PHP normally. We then use ob_get_clean to get the contents of the output buffer (which is your template file). and disable the output buffer, discarding it's contents, as we have the contents in $content
.