Re: Template class

From: Date: Wed, 12 Dec 2001 20:44:17 +0000
Subject: Re: Template class
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3468@lists.php.net to get a copy of this message
Hello, Lukas Smith wrote: > > Well i never understood putting any logic inside the templates > All the templates should do is use placeholders and blocks ... > > Anything beyond that is putting logic where it does not belong and you > are limiting yourself to designers that can also code I think you are absolutely right. Template engines that move logic and flow control from the scripts to the template files compromise maintainability when you want the designers just to design the HTML and the programmers just to program scripts and ones do not disturb the work of the others. This was a major concern when I started working on MetaL more than 2 years ago. So I design a meta-language compiler module that was able to look at template files and figure the different sections that the programs need to clip and substitute data marked in the template by code defined in the programs. The result was wonderful. The separation between HTML design and programming logic is complete. The meta-language module that I developed lets you define commands that make the compiler clip areas defined by the designers in the HTML and generate code that already does insertion mark substitution by the code that the developers write to use the clipped data from the HTML templates. This way, it is the programmer that defines in his programs the data that is substituted by his programming code and the designer only defines where in his HTML will be substituted what. You may see an example of application of the MetaL compiler template module in the code generated by this meta-programmed class for outputing general purpose HTML tables. http://phpclasses.upperdesign.com/browse.html/package/120 This is solution is way more efficient than any template class because you don't need a class to process your templates at runtime so you don't spend CPU cycles doing the same thing over and over again in each page access. This is why I never bothered writing any template engine classes despite you may find a toon of other developer template classes in the PHP Classes site here: http://phpclasses.upperdesign.com/browse.html/class/1 Regards, Manuel Lemos

« previous php.pear.dev (#3468) next »