Re: template module

From: Date: Sun, 05 Aug 2001 12:15:49 +0000
Subject: Re: template module
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-1299@lists.php.net to get a copy of this message
> But the main issue migth be how to use the factory pattern? > Rigth now, it doesn't seem possible to use 2 different template systems in > the same page. I would like to know if we can accept this limitation or not? Short: There should be no reason for this. We came the the the conclusion that, that we have to kinds of a template systems - a lightweight (IT) and a heavyweight (Smarty). The factory should provide a API to access the functions which offered by both systems. Ex: // could by 'heavyweight' too $template = new Template::factory("lightweight") ; $template -> setBlock( "Bigblock") ; $template -> assignData( "{VAR}", $content) ; $template -> parseBlock() ; Perhaps, if you need conditions in the template, you must switch to 'heavyweight' $template = new Template::factory("heavyweight") ; $template -> setBlock( "Bigblock") ; $template -> setCondition( $condition) ; $template -> assignData( "{VAR}", $content) ; $template -> parseBlock() ; That is the power of the factory pattern - changing the behavior with a minimum of rewriting. There is a idea in my mind - we could create a factory function, which doesn't expected the typ of system as parameter, separate a list of needed functionality. Ex: $need["ASSIGNDATA"] = true ; $need["BLOCKSUPPORT"] = true ; $need["CONDTIONS"] = true ; $need["SUCHOTHERSTUFF"] = false ; $template = new Template::CustomFactory( $need) ;

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