Sv: Re: New looping method proposal
| From: | anders dot janson at mailbox dot swipnet dot se | Date: | Mon, 19 Nov 2001 18:45:35 +0000 |
| Subject: | Sv: Re: New looping method proposal | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-1971@lists.php.net to get a copy of this message | ||
> I am willing to entertain the idea of this construct, because it will
> solve the problem of looping through non-sequential or associative
> arrays. However, I do not think that I want to use the same syntax as
> PHP does. Can we come up with something better?
OK, since it would actually solve a problem, I'll join the gang, and say "yes" to
this proposed addition.
I suggest you use the same structure for parameters as you have today, and reuse the parser code.
Perhaps even parts of the code generator could be recycled?
I noticed that "loop" was suggested as tag name, so here goes....
{loop name=whatever source=$my_array}
{$whatever.field1}<br>
{$whatever.field2}<br>
{/loop}
Other tag names could be "repeat", "iterate" or "sequence"
("seq"??).
I'll get flames for this, but I don't believe in different syntax for different tags.
Existing Smarty tags are built like {tag key1=value1 [keyN=valueN]}, and I vote for keeping it like
this.
/Anders
-------------------------------------------------
WebMail från Tele2 http://www.tele2.se
-------------------------------------------------