Re: PHPTAL / HTML_Template_PHPTAL (0.4.7) / GetText / Types

From: Date: Fri, 21 Mar 2003 01:25:25 +0000
Subject: Re: PHPTAL / HTML_Template_PHPTAL (0.4.7) / GetText / Types
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-14511@lists.php.net to get a copy of this message
Laurent Bedubourg wrote:
New version with a PEAR compliant name like proposed in earlier messages. For those who didn't follow PHPTAL last week episode, watch list archives or take a trip to its homepage PHPTAL has two dependencies for which i'd like PEAR point of view. I'm wondering if they will be of help for other projects or if i just have to integrate them to PHPTAL package without complaining :)
Hi Laurent, I've been testing your new version. Works really well but for a couple of problems... - although toString() method gets called when using tal:content etc it doesn't get called when using alternative ${path/to/object} syntax. Also, I wondered whether it might be better to make default call to eg 'valueOf()'. In Javascript toString() is used to give a textual view of the objects structure, whereas valueOf() returns a simple value. Wouldn't you say that 'toString()' is more like the Python __repr__() method which in the case of an array(1,2,3) would return eg [1, 2, 3], valueOf() might return 6 or 123. What do you think? - I've found that object references get copied rather than referenced to the variables in the compiled template which leads to some problems. I have eg a college object whose courseList object has a method called 'contains' which checks for a given scalar value in a list of course objects, but caches the values the first time round. But when used in the template the object is copied so the cached flag is not shared between the method calls in a tal:repeat sequence. See test.php and test.html in... http://www.the-moon.net/downloads/temp/tal_ivm-0.0.9.zip ...and take a look at the compiled template source.
* Types package : Types is a generic package that brings some OO wrapped types with a usefull Iterator interface.
I think standard types and an iterator interface should be added to pear. I use something similar to your iterator in my IVM package (also included in the zip file). I'd rather use method name 'getIterator()' than 'iterator()' in iterable objects. Another thing I wanted to ask you about is whether you have had any success using the iterator in a for loop rather than a while loop. I thought I could do... for ($i=&list->getIterator(),$i->first(); $i->hasNext(); $i->next() ) { // do stuff with $i->current } ...whilst also using same iterator interface in... while($i->hasNext()) { $i->next(); // do stuff with $i->current } ...but when i get it working in while loop it seems to skip first element in for loop. It's been doing my head in. Any thoughts greatly appreciated. I'll try and have a look at doing some docbook docs over the weekend. -RichardW.

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