Re: New looping method proposal

From: Date: Mon, 19 Nov 2001 19:17:48 +0000
Subject: Re: New looping method proposal
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1977@lists.php.net to get a copy of this message
On Mon, 19 Nov 2001, Monte Ohrt wrote: > Why don't we just make an alternative way of using {section ...} by > adding a new attribute: > > {* current syntax *} > {section name=contacts loop=$record} > {$record[contacts].firstname} > {/section} > > {* alternate associative array method *} > {section name=contacts each=$record} > {$contacts.firstname} > {/section} > > > So you require one of "loop" or "each", and we don't disturb the > language syntax so much. Well, the first thing that comes to mind is that the functionality of these two cases is very different. In the first one, 'name' attribute specifies the index and in the second one it names the variable that will be created as part of the loop. Also, what about all the section properties that people have come to associate with sections? And what about iterating over keys of the array as well? I don't like overloading constructs unless absolutely necessary, and having a separate {foreach .. } seems to be cleaner. The only problematic issue with it is implementation of .first, .last, and other section properties. -Andrei Work is of two kinds: first, altering the position of matter at or near the earth's surface relatively to other matter; second, telling other people to do so. The first kind is unpleasant and ill-paid, the second is pleasant and highly paid. -- Bertrand Russell

« previous php.smarty.general (#1977) next »