[dev] Re: [cvs] commit: horde/docs CHANGES framework/Template Template.php

Jason M. Felice jfelice at cronosys.com
Mon Mar 21 07:15:41 PST 2005


Jan Schneider wrote:

>Zitat von Jason Felice <jfelice at cronosys.com>:
>
>  
>
>>eraserhd    2005-03-19 11:13:22 PST
>>
>> Modified files:
>>   docs                 CHANGES
>>   Template             Template.php
>> Log:
>> * Allow Horde templates to include application blocks.
>>    
>>
>
>I have very strong objections against this patch for two reasons:
>
>1) Performance. There are a lot of template engines available, and quite a
>few with more features, a nicer syntax, whatever. We chose this template
>engine because it is fast, even without compiling templates. It is fast
>because it only uses PHP's string functions to parse and manipulate
>templates. You completely break this architecture using regexps, making the
>templates much slower as soon as you use the new feature, that means in
>*all* giapeto pages.
>  
>
Have we tested performance for string replaces versus regexps?  In the 
case of a straight search and replace, obviously, but with the "statements"?

That would be counter-intuitive to me, especially since we end up 
replacing the contents of the statements with an "extra" scan (we've 
already marked the beginning and ending of the area to replace), we end 
up re-scanning results of previosly-run statements, and we need to scan 
the template contents for each active variable.

But, I certainly have no problem with doing this the other way if it 
performs better.

>2) Abstraction. Until now, the template code was completely independent from
>Horde, making it interesting for usage outside of Horde too, e.g. when
>installed through Horde's PEAR server. Now we have a tight integration with
>internal Horde features, even if optional.
>
>What do you actually want to achieve? Global blocks on each giapeto page?
>This could be done much simpler and without even changing the template
>code. Add some logic to giapeto to define global blocks for each page, or
>even only for selected pages. Define a naming standard for tags that
>contain these blocks' contents and start using them in the templates. You
>could use simple tags like: <tag:block1 /> or <tag:block.1 />, have all the
>logic only  executed when and where necessary (in giapeto) and don't loose
>any performance in the general template code.
>  
>
I was answering the bounty put up by Chuck, so he'd have to answer what 
he was thinking.  One of our clients has requested the ability to put a 
search block in any template (for other apps, too), inline with their 
static HTML.  So perhaps my approach was informed by that.

More generally, I'd enjoy seeing the functionality consistent and 
available to all applications instead of what I imagine happening, which 
is that we copy and paste the code to render blocks to each page that 
needs it as we encounter the need.  I do hear your concern, and wonder 
if there is another way.

What about some sort of plugin mechanism?  Perhaps coupled with a 
<plugin:foo /> tag which will load Horde/Template/foo.php.  We could 
then put the Horde/Template/block.php in the framework/Block package.

-- 
 Jason M. Felice
 Cronosys, LLC <http://www.cronosys.com/>
 216.221.4600 x302



More information about the dev mailing list