From bf5ccccb527bb6496d642e6dc9612e929e31e8de Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 17 Dec 2024 11:31:27 +0100 Subject: [PATCH] Bug 38723: POC LOAD_FILTERS for raw --- C4/Templates.pm | 4 ++++ Koha/Template/Plugin/raw.pm | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index fb7d3e5cb56..8c7fe6e9978 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -70,6 +70,7 @@ sub new { # Do not use template cache if script is called from commandline my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE}; + use Koha::Template::Plugin::raw; my $template = Template->new( { EVAL_PERL => 1, ABSOLUTE => 1, @@ -77,6 +78,9 @@ sub new { COMPILE_EXT => $use_template_cache ? '.ttc' : '', COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '', INCLUDE_PATH => \@includes, + LOAD_FILTERS => [ + 'Koha::Template::Plugin::raw', + ], FILTERS => {}, ENCODING => 'UTF-8', } diff --git a/Koha/Template/Plugin/raw.pm b/Koha/Template/Plugin/raw.pm index f194a18ae2c..6e38be8be1c 100644 --- a/Koha/Template/Plugin/raw.pm +++ b/Koha/Template/Plugin/raw.pm @@ -17,8 +17,7 @@ package Koha::Template::Plugin::raw; use Modern::Perl; -use Template::Plugin::Filter; -use base qw( Template::Plugin::Filter ); +use base 'Template::Plugin'; our $DYNAMIC = 1; @@ -27,6 +26,13 @@ sub filter { return $text; } +sub fetch { + my ($self) = @_; + return sub { + return shift; + }; +} + 1; =head1 NAME -- 2.34.1