Quote:
Originally Posted by orjan
Well, how would a template engine work otherwise, if not being a mid-layer in between the produced data and the finished html?
in this way, you can, with the same code, in an very easy way, make totally different layouts with the same data, even for two users at the same time.
maybe there are better template engines, That I can't tell, but I've found the smarty engine to work well for me, then I can create my coding, and then a designer can work with the tpl-files how they like without disturbing the code at all, just inserting variables (and a few control parameters) into their design-html-code.
maybe you have some good suggestions of how to create layout templates in other ways?
|
You have described is the exact reason behind the MVC structure. I believe a template should be a separate layer of abstraction almost completely decoupled from the MVC itself. That said, I place my "template" in then front controller. The front controller then loads the individual page controllers (and thus the associated models and views).
I have never used it, but
phpSavant does not compile the template which makes a whole lot more sense to me.