/[webpac2]/trunk/lib/WebPAC/Output/TT.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Output/TT.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 21 by dpavlin, Sun Jul 17 22:28:11 2005 UTC revision 42 by dpavlin, Mon Nov 14 16:11:40 2005 UTC
# Line 6  use strict; Line 6  use strict;
6  use base qw/WebPAC::Common/;  use base qw/WebPAC::Common/;
7    
8  use Template;  use Template;
9    use List::Util qw/first/;
10  use Data::Dumper;  use Data::Dumper;
11    
12  =head1 NAME  =head1 NAME
# Line 69  Create output from in-memory data struct Line 70  Create output from in-memory data struct
70    
71   my $text = $tt->apply(   my $text = $tt->apply(
72          template => 'text.tt',          template => 'text.tt',
73          data => @ds          data => \@ds
74   );   );
75    
76  =cut  =cut
# Line 85  sub apply { Line 86  sub apply {
86                  $log->logconfess("need $a") unless ($args->{$a});                  $log->logconfess("need $a") unless ($args->{$a});
87          }          }
88    
89            # filter to return value from @ds
90    
91            sub tt_filter_d {
92    
93                    my ($name,$join) = @_;
94    
95    print "### name = ",Dumper($name);
96    
97                    my $item = first { $_->{'name'} eq $name } @{ $args->{'data'} };
98    
99                    return unless($item);
100    
101    print "### item = ",Dumper($item);
102    
103                    my $v = $item->{'display'} || return;
104    
105                    if (ref($v) eq 'ARRAY') {
106                            if ($#{$v} == 0) {
107                                    $v = $v->[0];
108                            } else {
109                                    $join = '&#182;<br/>' unless defined($join);
110                                    $v = join($join, @{$v});
111                            }
112                    }
113    print "### v = $v\n";
114                    return $v;
115            }
116            $args->{'d'} = \&tt_filter_d;
117    
118    
119          my $out;          my $out;
120    
121          $self->{'tt'}->process(          $self->{'tt'}->process(
# Line 104  to a file. Line 135  to a file.
135   $tt->to_file(   $tt->to_file(
136          file => 'out.txt',          file => 'out.txt',
137          template => 'text.tt',          template => 'text.tt',
138          data => @ds          data => \@ds
139   );   );
140    
141  =cut  =cut

Legend:
Removed from v.21  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26