If your template files are actually html, like this:
<a href="page2.html" target="_blank">This is my link!</a></html>
That is a problem, because that is not PHP, you are trying to evaluate HTML as PHP, which is wrong.
Your html template files must be in this format:
$str="<a href=\"page2.html\" target=\"_blank\">This is my link!</a></html>";