Re: an HTML_Template_IT[X] fork is available

From: Date: Tue, 11 Feb 2003 12:14:57 +0000
Subject: Re: an HTML_Template_IT[X] fork is available
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13095@lists.php.net to get a copy of this message
<borz_off@cs.msu.su> wrote : > Greetings! > > Several months ago I wrote to this list proposing my private fork of these > template classes for merging: > > http://marc.theaimsgroup.com/?l=pear-dev&m=103242445816080&w=2 > > Well, at that time the fork had some problems: > 1) It was one file instead of IT.php/ITX.php > 2) The comments were in Russian > 3) Callback functions were not implemented. > > This time I am back with a drop-in replacement for PEAR's HTML_Template_IT[X]. > As the development of IT[X] is effectivelly stalled and its current maintainer > wasn't interested in new features back then (see the archives), I propose > replacing the current code in PEAR repository with my work. I am also willing > to become its developer (or a maintainer, if the current one resigns). > I must point out that making a patch against current sources was impractical, > as the classes are almost completely rewritten. > > The classes are available for review: > http://158.250.10.119/pear/IT.phps > http://158.250.10.119/pear/ITX.phps > http://158.250.10.119/pear/ITMod.phps (my original work, > don't bother if you > don't read Russian) > > They also can be dowloaded with a readme file describing new > features/incompatibilities from > http://158.250.10.119/pear/IT[X]-fork.tar.gz > > here is the part of this readme: > ------------------ > HTML_Template_IT > > 1) New features and improvements: > a) Transparent caching of prepared templates. You just have to pass a second > parameter to the constructor: a directory name (the directory should be > writable for PHP). After the template gets parsed for blocks and > variables, the resultant arrays are serialized and saved into files in > this directory. The next time the template file needs to be loaded, the > prepared one is loaded instead, with a cheap unserialize() instead of > very expensive RegExp matching logic. > > b) Global variables. Variables set by a function setGlobalVariable() do > not get cleared after first substitution, unlike ordinary ones, and do > not trigger "block not empty" logic (block with only global variables is > still considered "empty"). Can be used for directory prefixes, session > identifiers and the stuff like that. > > c) hideBlock(): an opposite of touchBlock(). It prevents block from > appearing in the result even if it is "not empty". > > d) The source was cleaned, PEARified and optimised. Inline docs were updated > > 2) Removed features and incompatibilities: > a) $flagCacheTemplatefile and related logic was dropped in favor of a more > generic approach, see (1.a) > > b) $clearCache and $clearCacheOnParse were removed (now the engine works as > if they are always false) > > c) Public functions init() and free() are removed, they were unusable > unless called from setTemplate() anyway... > > d) Using <!-- INCLUDE something --> in template is no more possible. If one > needs unconditional include, he should consider joining the templates > into single file, if one needs something more useful, he should use ITX > with its addBlockfile() method. > > HTML_Template_ITX > > 3) New features and improvements: > a) Transparent caching (1.a) also works for addBlockfile() and > replaceBlockfile() > > b) Error handling war PEARified. It was completely broken in stock version > as it relied on class IT_Error from file IT_Error.php which never got > included... > > c) Cleanups. > > 2) Removed features and incompatibilities: > a) Public functions getFunctioncalls(), setFunctioncontent(), > setCallbackFuntiontable() (sic!), getBlocklist(), > getBlockvariables(), BlockvariableExists() were removed. > > b) replaceBlock() implementation is somewhat different from stock version.. > > c) Callback functions and caching do not mix. If you pass a second parameter > to the constructor, the template WILL NOT be parsed for function calls.. > If you attempt to call setCallbackFunction() of performCallback() > afterwards, an error will be thrown. > > ------------------ Hi Alexey, I am a definitive supporter of your version, and I think that having a maintainer that does his job is a good thing for this package. Did you manage to improve the parsing in terms of speed ? I've been using the previous version you proposed and noticed some incompatibilities on the touchBlock() method with the stock version. How do you handle this now ? Thanks, Bertrand Mansion Mamasam

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