In working on a framework created by myself and two other people, we decided to employ the latter approach. The resulting architecture had us create two separate files for every one page: an ACTION file (logic) and a PAGE file (template). We all agreed to swear by the following two rules:
- ACTION files should never contain any HTML whatsoever.
- PAGE files could only use PHP for basic scenario-handling conditionals, outputting data passed from the ACTION file, looping through arrays passed from the ACTION file, and basic functions used to format data passed from the ACTION file.
In approaching template and logic separation this way, I don't feel anything except success. We've got a solid working system that doesn't have any of the overhead attached with regularly parsing template files, none of the nuisance involved with having to learn yet another obscure templating syntax, but is far more flexible solely because it utilizes PHP itself. If I spent some time improving the caching system for some further speed gains, I can't see how something like Smarty would ever possibly keep up.
Having said all that, what advantages would using a parsed system like Smarty provide that the above method wouldn't? Am I wrong or too arrogant in my statements?