View | Details | Raw Unified | Return to bug 19578
Collapse All | Expand All

(-)a/C4/Letters.pm (-1 / +25 lines)
Lines 1473-1479 sub _process_tt { Link Here
1473
1473
1474
    my $tt_params = { %{ _get_tt_params( $tables ) }, %{ _get_tt_params( $loops, 'is_a_loop' ) }, %$substitute };
1474
    my $tt_params = { %{ _get_tt_params( $tables ) }, %{ _get_tt_params( $loops, 'is_a_loop' ) }, %$substitute };
1475
1475
1476
    $content = qq|[% USE KohaDates %]$content|;
1476
    $content = add_tt_filters( $content );
1477
    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
1477
1478
1478
    my $output;
1479
    my $output;
1479
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
1480
    $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
Lines 1500-1505 sub _get_tt_params { Link Here
1500
            plural   => 'biblios',
1501
            plural   => 'biblios',
1501
            pk       => 'biblionumber',
1502
            pk       => 'biblionumber',
1502
        },
1503
        },
1504
        biblioitems => {
1505
            module   => 'Koha::Biblioitems',
1506
            singular => 'biblioitem',
1507
            plural   => 'biblioitems',
1508
            pk       => 'biblioitemnumber',
1509
        },
1503
        borrowers => {
1510
        borrowers => {
1504
            module   => 'Koha::Patrons',
1511
            module   => 'Koha::Patrons',
1505
            singular => 'borrower',
1512
            singular => 'borrower',
Lines 1649-1654 sub _get_tt_params { Link Here
1649
    return $params;
1656
    return $params;
1650
}
1657
}
1651
1658
1659
=head3
1660
1661
$content = add_tt_filters( $content );
1662
1663
Add TT filters to some specific fields if needed.
1664
1665
For now we only add the Remove_MARC_punctuation TT filter to biblio and biblioitem fields
1666
1667
=cut
1668
1669
sub add_tt_filters {
1670
    my ( $content ) = @_;
1671
    $content =~ s|\[%\s*biblio\.(.*?)\s*%\]|[% biblio.$1 \| \$Remove_MARC_punctuation %]|gxms;
1672
    $content =~ s|\[%\s*biblioitem\.(.*?)\s*%\]|[% biblioitem.$1 \| \$Remove_MARC_punctuation %]|gxms;
1673
    return $content;
1674
}
1675
1652
=head2 get_item_content
1676
=head2 get_item_content
1653
1677
1654
    my $item = Koha::Items->find(...)->unblessed;
1678
    my $item = Koha::Items->find(...)->unblessed;
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +41 lines)
Lines 19-25 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 17;
22
use Test::More tests => 18;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use MARC::Record;
25
use MARC::Record;
Lines 894-899 subtest 'loops' => sub { Link Here
894
    };
894
    };
895
};
895
};
896
896
897
subtest 'add_tt_filters' => sub {
898
    plan tests => 1;
899
    my $code   = "TEST";
900
    my $module = "TEST";
901
902
    my $patron = $builder->build_object(
903
        {
904
            class => 'Koha::Patrons',
905
            value => { surname => "with_punctuation_" }
906
        }
907
    );
908
    my $biblio = $builder->build_object(
909
        { class => 'Koha::Biblios', value => { title => "with_punctuation_" } }
910
    );
911
    my $biblioitem = $builder->build_object(
912
        {
913
            class => 'Koha::Biblioitems',
914
            value => {
915
                biblionumber => $biblio->biblionumber,
916
                isbn         => "with_punctuation_"
917
            }
918
        }
919
    );
920
921
    my $template = q|patron=[% borrower.surname %];biblio=[% biblio.title %];biblioitems=[% biblioitem.isbn %]|;
922
    reset_template( { template => $template, code => $code, module => $module } );
923
    my $letter = GetPreparedLetter(
924
        module      => $module,
925
        letter_code => $code,
926
        tables      => {
927
            borrowers   => $patron->borrowernumber,
928
            biblio      => $biblio->biblionumber,
929
            biblioitems => $biblioitem->biblioitemnumber
930
        }
931
    );
932
    my $expected_letter = q|patron=with_punctuation_;biblio=with_punctuation;biblioitems=with_punctuation|;
933
    is( $letter->{content}, $expected_letter, );
934
};
935
936
897
sub reset_template {
937
sub reset_template {
898
    my ( $params ) = @_;
938
    my ( $params ) = @_;
899
    my $template   = $params->{template};
939
    my $template   = $params->{template};
900
- 

Return to bug 19578