Re: Re: IT[X] addBlock()

From: Date: Thu, 20 Dec 2001 11:48:28 +0000
Subject: Re: Re: IT[X] addBlock()
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3564@lists.php.net to get a copy of this message
"Vitaly N. Kravchenko" wrote: > Ulf? I've lost the question, but maybe this example proofs that (at least) addBlock() works fine with the lastest CVS version. Well the code I used should be equal to the CVS version, it's the code I used to do my latest commits. ---8<---8<---8<---8<---8<---8<---8<---8<--- main.html: begin of main.html <hr> <p> <!-- BEGIN main_loop --> Main {MAIN_COUNTER}<br> <!-- END main_loop --> </p> <hr> {INCLUDED} <hr> end of main.html ---8<---8<---8<---8<---8<---8<---8<---8<--- included.html: first line of included.html <hr> <p>{DATE}</p> <p> <ul> <!-- BEGIN included_outer --> <li>Outer {OUTER_COUNTER} <ul> <!-- BEGIN included_inner --> <li>Inner {INNER_COUNTER}</li> <!-- END included_inner --> </ul> </li> <!-- END included_outer --> </ul> <hr> last line of included.html ---8<---8<---8<---8<---8<---8<---8<---8<--- PHP script: require_once('./ITX.php'); $itx = new IntegratedTemplateExtension(dirname(__FILE__)); $itx->loadTemplateFile('main.html'); // loop of main.html $itx->setCurrentBlock('main_loop'); for ($i = 0; $i < 3; $i++) { $itx->setVariable('MAIN_COUNTER', $i); $itx->parseCurrentBlock(); } // the magic addBlock(), note that you turn {INLUDED} into // a block named 'block_included' ! $itx->addBlockFile('INCLUDED', 'block_included', 'included.html'); // parse some nested blocks - start with the innermost! for ($i = 0; $i < 3; $i++) { $itx->setCurrentBlock('included_inner'); for ($j = 0; $j < 3; $j++) { $itx->setVariable('INNER_COUNTER', $j); $itx->parseCurrentBlock(); } $itx->setCurrentBlock('included_outer'); $itx->setVariable('OUTER_COUNTER', $i); $itx->parseCurrentBlock(); } $itx->setCurrentBlock('block_included'); $itx->setVariable('DATE', date('Y-m-d', time())); $itx->parseCurrentBlock(); $itx->show(); ---8<---8<---8<---8<---8<---8<---8<---8<--- Output: begin of main.html <hr> <p> Main 0<br> Main 1<br> Main 2<br> </p> <hr> first line of included.html <hr> <p>2001-12-20</p> <p> <ul> <li>Outer 0 <ul> <li>Inner 0</li> <li>Inner 1</li> <li>Inner 2</li> </ul> </li> <li>Outer 1 <ul> <li>Inner 0</li> <li>Inner 1</li> <li>Inner 2</li> </ul> </li> <li>Outer 2 <ul> <li>Inner 0</li> <li>Inner 1</li> <li>Inner 2</li> </ul> </li> </ul> <hr> last line of included.html <hr> end of main.html ---8<---8<---8<---8<---8<---8<---8<---8<--- Ulf ---8<---8<---8<---8<---8<---8<---8<---8<---

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