I'm trying to build a CMS in PHP and having a little trouble with building a template system. I don't want to use Smarty or Twig because I don't want to rely on external frameworks until I can fluently code myself. It is all about enhancing my learning (from my perspective).
So I have been planning out how the templating will work but have run into trouble with the error checking.
Here is a basic overview of how it works.
(very) simple sample template:
<html>
<p>{output $randomNumber}</p>{output $databaseDump}
<div>{output $databaseAndUsersPasswords}</div>
</html>
Gets parsed by my parser:
<html>
<p><?php echo $randomNumber?></p><?php echo $databaseDump?>
<div><?php echo $databaseAndUsersPasswords?></div>
</html>
Then I use eval to run the parsed template.
Where my issue lies is in Error checking. If a designer were to get something wrong there is very little protection against an error. With error suppression enabled a portion of the page will just be missing its content. I want it to be all or nothing. I can't think of a simple solution that will allow me to check for errors.
Also, do you think I am okay using regular expression and str_replace to parse the template? I have been reading over some other frameworks solutions, but it all looks terribly over complicated, I can't locate the core of their parsing system.
Please criticize my techniques all you like. I am here to learn.