From 12c6ff8f4acd5f1f8c394cb059c7e6663d16f7c2 Mon Sep 17 00:00:00 2001
From: Kyle Hall <kyle@bywatersolutions.com>
Date: Wed, 22 Feb 2023 13:16:35 -0500
Subject: [PATCH] Bug 33045: Use process_tt in C4::Record::marcrecord2csv

Bug 33030 implements a new helper subroutine to standardize processing of Template Toolkit syntax outside slips and notices. We should use this subroutine in marcrecord2csv.

Test Plan:
1) Apply this patch
2) prove t/db_dependent/Record/marcrecord2csv.t
---
 C4/Record.pm | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/C4/Record.pm b/C4/Record.pm
index 69a60f3520..9f0d21c491 100644
--- a/C4/Record.pm
+++ b/C4/Record.pm
@@ -38,6 +38,7 @@ use Koha::SimpleMARC qw( read_field );
 use Koha::XSLT::Base;
 use Koha::CsvProfiles;
 use Koha::AuthorisedValues;
+use Koha::TemplateUtils qw( process_tt );
 use Carp qw( carp croak );
 
 use vars qw(@ISA @EXPORT);
@@ -564,13 +565,10 @@ sub marcrecord2csv {
 
         # TT tags exist
         if ( $content =~ m|\[\%.*\%\]| ) {
-            my $tt = Template->new();
-            my $template = $content;
             # Replace 00X and 0XX with X or XX
             $content =~ s|fields.00(\d)|fields.$1|g;
             $content =~ s|fields.0(\d{2})|fields.$1|g;
-            my $tt_output;
-            $tt->process( \$content, $field_list, \$tt_output );
+            my $tt_output = process_tt( $content, $field_list );
             push @csv_rows, $tt_output;
         } else {
             for my $tag ( @$tags ) {
-- 
2.30.2