Thanks for your help. I have this code:

sub output {
   my ($tmpl, $data, $level, $oldref, $listref)=@_;

   my @dataKeys = keys (%$data);
   map {$_=lc($_)} @dataKeys;

   foreach my $param (@{$listref}) 
   {
      my @k = @{$oldref};
      push @k, $param;
    
      if (not in ($param, @dataKeys))
      {
         my $message = "tmpl variable '".join('.', @k)."' not find in data.
Data dumper: \n";
         $message .= Dumper($data);
         warn ($message);
      }   
      
      if ($tmpl->query('name' => \@k) eq 'LOOP') 
      {
         foreach my $loopData (@{$data->{$param}})
         {
            my @l=$tmpl->query('loop' => \@k);
            &output($tmpl, $loopData, $level+1, \@k, \@l);
         }
      }
   }
}

Maybe this code be a option in the Template itself Mr Sam Tregar.  

Thanks
Marcos Rebelo


> On Wed, Dec 11, 2002 at 10:45:03AM +0000, Marcos Rebelo wrote:
> >Instead of using the ?defined? I can use the ?exists?. The problem is if the

> >tmpl_var is inside a tmpl_loop. 
> >Can I have access to the tmpl_var there?
> 
> Yes.
> 
> It's time for me to post the template dumper again, isn't it? Run this
> against a template, and you'll get a hierarchical list of the variables
> in it. Extending this to test whether each variable is defined shouldn't
> be particularly difficult; I haven't had a need to, so I haven't written
> it.
> 
> 
> #! /usr/bin/perl -w
> 
> use strict;
> use HTML::Template;
> 
> my $t=HTML::Template->new(filename => $ARGV[0],
>                           die_on_bad_params => 0);
> my @l=$t->param;
> my @o;
> &output(0,\@o,\@l);
> 
> sub output {
>   my ($level,$oldref,$listref)=@_;
>   my @list=@{$listref};
>   my @old=@{$oldref};
>   foreach my $param (sort @list) {
>     my @k=@old;
>     push @k,$param;
>     print ' ' x $level;
>     print "$param\n";
>     if ($t->query('name' => \@k) eq 'LOOP') {
>       my @l=$t->query('loop' => \@k);
>       &output($level+1,\@k,\@l);
>     }
>   }
> }
> 
> 
> Roger
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:
> With Great Power, Comes Great Responsibility 
> Learn to use your power at OSDN's High Performance Computing Channel
> http://hpc.devchannel.org/
> _______________________________________________
> Html-template-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/html-template-users
-- 
10Mb na sua caixa de email gratuita no mail.pt
http://www.mail.pt



-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility 
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to