r8980@llin: dpavlin | 2005-11-20 00:49:22 +0100
[webpac2] / lib / WebPAC / Output / TT.pm
index 77eb897..d9bd3a1 100644 (file)
@@ -70,7 +70,7 @@ Create output from in-memory data structure using Template Toolkit template.
 
  my $text = $tt->apply(
        template => 'text.tt',
-       data => \@ds
+       data => $ds
  );
 
 It also has follwing template toolikit filter routies defined:
@@ -90,7 +90,7 @@ sub apply {
 
 =head3 tt_filter_type
 
-filter to return values of specified from @ds
+filter to return values of specified from $ds
 
 =cut
 
@@ -109,13 +109,11 @@ filter to return values of specified from @ds
 
                        my ($name,$join) = @_;
 
-                       die "no data array" unless ($data->{'data'} && ref($data->{'data'}) eq 'ARRAY');
+                       die "no data hash" unless ($data->{'data'} && ref($data->{'data'}) eq 'HASH');
                        # Hm? Should we die here?
                        return unless ($name);
 
-                       my $item = first { $_->{'name'} eq $name } @{ $data->{'data'} };
-
-                       return unless($item);
+                       my $item = $data->{'data'}->{$name} || return;
 
                        my $v = $item->{$type} || return;
 
@@ -153,7 +151,7 @@ to a file.
  $tt->to_file(
         file => 'out.txt',
        template => 'text.tt',
-       data => \@ds
+       data => $ds
  );
 
 =cut