[Phplib-users] template extensions
Brought to you by:
nhruby,
richardarcher
From: Evan H. <hu...@bi...> - 2003-01-14 19:51:05
|
Richard Archer wrote: > The philosophy of the template class is to separate the data > presentation from the application logic. template.inc does this, and > does it very well (and with good performance into the bargain). The approach that Mike and I are suggesting improves that separation, without any negative impact on performance (I'm speaking from a theoretical perspective: I haven't implemented this, so I can't be certain). Currently there is a tight coupling between code and templates because variables corresponding to dynamic content must be defined explicitly in php. This means that there is either a hand crafted php script sitting in front of every template, or there are more variables being defined than are necessary. The proposed approach would sever that connection. Instead of a hand-crafted script sitting in front of each template defining variables (in a coder-dependant manner that may or may not encourage reuse), there would be a standard location where dynamically generated content would live. As a template is evaluated, and reference to that content are detected, it would be imported and generated. Notice that lovingly hand-crafted scripts (made by italian monks to the highest standards, using a secret process handed down from their celebate forefathers) are no longer necessary. All templates can be treated the same. Notice that all dynamically generated content in a site is now put into a single location and forced to be encapsulated (there are arguments against wholesale encapsulation, but that's where php's 'include' statement comes into play). > Once you start adding scripting to a template class, where do you stop. These would not be scripting components. They would be references to files to run and include (a la server-side-includes, php's include, and a plethora of inclusion tools). There would be no logic stored in the templates: no control structures, no variables, no operators, no expressions. All we are suggesting is late binding. Instead of doing all of the variable/value binding up front (before the template is evaluated), we would allow it to be done later in the run cycle (on demand). > You finish up re-implementing PHP within PHP. And you open up a whole > lot of security concerns which designers shouldn't need to worry about. Again: no. There would be no difference between this mechanism and the existing include mechanism. > And you kill your performance. Not according to the architecture we have suggested. -- Evan Hughes OpenConcept Consulting (openconcept.ca) |