Loading your own namespace would not prevent PHPTAL's built in attributes, I 
think.

But note that registering namespace costs much to load PHPTAL's parser engine.

So I'm using pre-filter mechanism to load my namespace classes because
PHPTAL_PreFilter class is very small and not related to other parts of PHPTAL.

When I already have parsed template in my cache dir, it does never cost to load
parser engine and namespaces. Then the filter() method would be ignored
instead cached code would be used.  I can pay to just only PHPTAL_PreFilter :)


On 2012/09/20, at 23:31, Clouts wrote:

> I've added my own namespace using:
> PHPTAL_Dom_Defs::getInstance()->registerNamespace(new MyNewNS());
> 
> And defined the NS class as:
> /* ************************************
> *
> */ /* ***************************** */
> class MyNewNS extends PHPTAL_Namespace_Builtin
> {
> /* ************************************
> *
> */ /* ***************************** */
>    public function __construct(){
>        parent::__construct('MyNewNS', 'http://ctrlogic.net/tpl/phptal/ns');
>        $this->addAttribute(new PHPTAL_NamespaceAttributeSurround('att', 4));
>    }
> }
> 
> And defined the Attribute class as:
> /* ************************************
> *
> */ /* ***************************** */
> class PHPTAL_Php_Attribute_MyNewNS_att extends PHPTAL_Php_Attribute
> {
> /* ************************************
> *
> */ /* ***************************** */
>    public function before(PHPTAL_Php_CodeWriter $codewriter)
>    {
> $code = <<<code
> Some php code here
> code;
>        $codewriter->pushCode($code);
>    }
> /* ************************************
> *
> */ /* ***************************** */
>    public function after(PHPTAL_Php_CodeWriter $codewriter)
>    {
>    }
> }
> 
> Is there any way not having this attribute class inside the PHPTAL installed 
> repository?
> 
> I want to have it outside the PHPTAL installed repository...
> 
> Would preloading it prevent PHPTAL from searching the class inside its own 
> installed repository?
> 
> 
> _______________________________________________
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal

-- 
Hisateru Tanaka
tanakahisat...@gmail.com


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to