--- trunk2/lib/WebPAC.pm 2004/10/10 11:04:52 500 +++ trunk2/lib/WebPAC.pm 2004/10/30 23:04:37 560 @@ -47,6 +47,7 @@ There is optinal parametar C which specify different filters which can be applied using C notation. +Same filters can be used in Template Toolkit files. This method will also read configuration files C (used by indexer and Web font-end) @@ -112,9 +113,7 @@ # create Template toolkit instance $self->{'tt'} = Template->new( INCLUDE_PATH => ($self->{'global_config_file'}->{'output_template'} || './output_template'), -# FILTERS => { -# 'foo' => \&foo_filter, -# }, + FILTERS => $self->{'filter'}, EVAL_PERL => 1, ); @@ -570,6 +569,8 @@ # iteration (for repeatable fields) my $i = shift || 0; + $log->logdie("infitite loop in format $format") if ($i > ($self->{'max_mfn'} || 9999)); + # FIXME remove for speedup? $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o); @@ -588,7 +589,10 @@ $filter_name = $1 if ($format =~ s/^filter{([^}]+)}//s); # do actual replacement of placeholders + # repeatable fields $format =~ s/v(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,$i,\$found)/ges; + # non-repeatable fields + $format =~ s/s(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,0,\$found)/ges; if ($found) { $log->debug("format: $format"); @@ -701,13 +705,17 @@ my $prefix; my $all_found=0; - while ($format =~ s/^(.*?)v(\d+)(?:\^(\w))?//s) { + while ($format =~ s/^(.*?)(v|s)(\d+)(?:\^(\w))?//s) { my $del = $1 || ''; $prefix ||= $del if ($all_found == 0); + # repeatable index + my $r = $i; + $r = 0 if (lc("$2") eq 's'); + my $found = 0; - my $tmp = $self->get_data(\$rec,$2,$3,$i,\$found); + my $tmp = $self->get_data(\$rec,$3,$4,$r,\$found); if ($found) { push @out, $del; @@ -731,7 +739,7 @@ } if ($eval_code) { - my $eval = $self->fill_in($rec,$eval_code,$i); + my $eval = $self->fill_in($rec,$eval_code,$i) || return; $log->debug("about to eval{$eval} format: $out"); return if (! $self->_eval($eval)); } @@ -927,7 +935,7 @@ # delimiter (or ,) my $d = $tag->{'delimiter'}; # default delimiter - $d ||= ", "; + $d ||= " "; my $last = pop @{$row->{$type}}; $d = "" if (! $last);