On Sun, Nov 28, 2004 at 07:07:22PM +0000, Markus Linke wrote:
> Hi,
> 
> I am trying to use the template toolkit to built configuration files
> for a network management system.
> 
> Currently the data-structure looks like this:
> 
> $VAR1 = {

[ snip - a simpler expample would have worked just as well :) ]

>         };
> 
> I would like to create several config-files out of this information
> (hostlist, all "pingable" hosts, dependencies, ...), but I didnt work
> out how to access such a data-structure, because the "keys" change all
> the time. In perl it works fine with a foreach loop, but with the
> template toolkit I dont know how do to that.
> 
> Do I have to change the datastructure or does anybody have a good idea
> how to do this?

Given a hash (let's call it hash) to can walk its contents like this:

[% FOREACH key IN hash.keys %]
  [% key %] is [% hash.$key %]
[% END %]

The key (no pun intended) is using $key on the hash lookup instead of
just 'key' - which would look for a key with the literal value 'key'.

Dave...

-- 
  If there's something inside that you wanna say
  Say it out loud it'll be ok

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to