47 |
|
|
48 |
There is optinal parametar C<filter> which specify different filters which |
There is optinal parametar C<filter> which specify different filters which |
49 |
can be applied using C<filter{name}> notation. |
can be applied using C<filter{name}> notation. |
50 |
|
Same filters can be used in Template Toolkit files. |
51 |
|
|
52 |
This method will also read configuration files |
This method will also read configuration files |
53 |
C<global.conf> (used by indexer and Web font-end) |
C<global.conf> (used by indexer and Web font-end) |
113 |
# create Template toolkit instance |
# create Template toolkit instance |
114 |
$self->{'tt'} = Template->new( |
$self->{'tt'} = Template->new( |
115 |
INCLUDE_PATH => ($self->{'global_config_file'}->{'output_template'} || './output_template'), |
INCLUDE_PATH => ($self->{'global_config_file'}->{'output_template'} || './output_template'), |
116 |
# FILTERS => { |
FILTERS => $self->{'filter'}, |
|
# 'foo' => \&foo_filter, |
|
|
# }, |
|
117 |
EVAL_PERL => 1, |
EVAL_PERL => 1, |
118 |
); |
); |
119 |
|
|
569 |
# iteration (for repeatable fields) |
# iteration (for repeatable fields) |
570 |
my $i = shift || 0; |
my $i = shift || 0; |
571 |
|
|
572 |
|
$log->logdie("infitite loop in format $format") if ($i > ($self->{'max_mfn'} || 9999)); |
573 |
|
|
574 |
# FIXME remove for speedup? |
# FIXME remove for speedup? |
575 |
$log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o); |
$log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o); |
576 |
|
|
589 |
$filter_name = $1 if ($format =~ s/^filter{([^}]+)}//s); |
$filter_name = $1 if ($format =~ s/^filter{([^}]+)}//s); |
590 |
|
|
591 |
# do actual replacement of placeholders |
# do actual replacement of placeholders |
592 |
|
# repeatable fields |
593 |
$format =~ s/v(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,$i,\$found)/ges; |
$format =~ s/v(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,$i,\$found)/ges; |
594 |
|
# non-repeatable fields |
595 |
|
$format =~ s/s(\d+)(?:\^(\w))?/$self->get_data(\$rec,$1,$2,0,\$found)/ges; |
596 |
|
|
597 |
if ($found) { |
if ($found) { |
598 |
$log->debug("format: $format"); |
$log->debug("format: $format"); |
705 |
my $prefix; |
my $prefix; |
706 |
my $all_found=0; |
my $all_found=0; |
707 |
|
|
708 |
while ($format =~ s/^(.*?)v(\d+)(?:\^(\w))?//s) { |
while ($format =~ s/^(.*?)(v|s)(\d+)(?:\^(\w))?//s) { |
709 |
|
|
710 |
my $del = $1 || ''; |
my $del = $1 || ''; |
711 |
$prefix ||= $del if ($all_found == 0); |
$prefix ||= $del if ($all_found == 0); |
712 |
|
|
713 |
|
# repeatable index |
714 |
|
my $r = $i; |
715 |
|
$r = 0 if (lc("$2") eq 's'); |
716 |
|
|
717 |
my $found = 0; |
my $found = 0; |
718 |
my $tmp = $self->get_data(\$rec,$2,$3,$i,\$found); |
my $tmp = $self->get_data(\$rec,$3,$4,$r,\$found); |
719 |
|
|
720 |
if ($found) { |
if ($found) { |
721 |
push @out, $del; |
push @out, $del; |
899 |
|
|
900 |
if ($tag->{'sort'}) { |
if ($tag->{'sort'}) { |
901 |
@v = $self->sort_arr(@v); |
@v = $self->sort_arr(@v); |
|
$log->warn("sort within tag is usually not what you want!"); |
|
902 |
} |
} |
903 |
|
|
904 |
# use format? |
# use format? |