[Templates] hash key
Josh Rosenbaum
josh@infogears.com
Tue, 14 Feb 2006 18:29:18 -0700
Sergey Martynoff wrote:
> Or do you need to preserve that "box_$i" order? No problem:
>
> [% FOREACH hash.list.sort( 'key' ) %]
> the "box" key is [% key %]
> name is [% value.name %]
> phone is [% value.phone %]
> [% END %]
I'd probably avoid that usage since hash.list will be changed in TT3, and if Tim upgrades it'll be more work to fix. (See note in CHANGES for upcoming 2.15.)
Here's another method if Tim is just looking for a shorter way to do things. (Sorted by the keys in hash (ie: 'box_1') which seems to be the original intent.)
[% FOREACH key IN hash.keys.sort() %]
[% name = hash.$key.name %]
[% phone = hash.$key.phone %]
[% END %]
Although the order would get screwed up when the keys contain integers greater than 9 (ie: 'box_10' would be right after 'box_1')
Can't really help here, though, without more details.
-- Josh