Re: Play nice! Re: Savant/Flexy/Foo template engines

From: Date: Thu, 10 Jun 2004 20:25:39 +0000
Subject: Re: Play nice! Re: Savant/Flexy/Foo template engines
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30424@lists.php.net to get a copy of this message
Hi again, This revision includes support for user-defined filters. The user defines filters with the $filters property like so: $tpl =& new Template(); $tpl->filter[] = 'base64_encode'; // a function as a filter $tpl->filter[] = array($search_regex, $replace_regex); // a regex pair as a filter $tpl->filter[] =& new Filter_Object(); // an object with a filter() method These get called, in order, at the end of toString() by the filter() method. Might be better to have the filter() code in toString(), don't know. By the way, Alan, I tried reworking the output() method the way you said, so that toString would just start a buffer and capture output; the problem is that output() can't filter on its own; filters need a buffered string to work with. So it's back to toString() being the heart, buffer and all. Also note that I don't have file-path searching in this revision; that can be handled by the compiler object (which need not be a a "compiler" per se, it could just as well be called a pre-processor). Keeps the baseline template object sleek. :-) http://wiki.ciaweb.net/yawiki/index.php?area=Savant&page=TemplateSource I'm no longer sure that adding plugin methods to the basic Template class is wise; perhaps a separate plugin object can be assigned, and it can handle plugin calls. Don't know. -- Paul M. Jones Savant: the simple alternative to Smarty for PHP. http://phpsavant.com/ DB_Table: build RDBMS tables and XHTML forms in one PHP class. http://wiki.ciaweb.net/yawiki/index.php?area=DB_Table Yawiki: your collaborative online documentation system. http://yawiki.com/ Yawp: a single-file foundation for PHP applications. http://phpyawp.com/

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