From ee7d6249e2048c6f680dae5fe13a4b0372e3ff01 Mon Sep 17 00:00:00 2001 From: Kevin Carnes Date: Fri, 9 Aug 2024 15:52:31 +0200 Subject: [PATCH] Bug 36171: Fix template toolkit tags split by HTML parser --- C4/TTParser.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/C4/TTParser.pm b/C4/TTParser.pm index 7007fb6604..c4e2aa8a4e 100644 --- a/C4/TTParser.pm +++ b/C4/TTParser.pm @@ -73,6 +73,22 @@ sub text{ my $line = shift; my $work = shift; # original text my $is_cdata = shift; + # If there is a split template toolkit tag + if( $work =~ m/.*?%\]/s && index($&, '[%') == -1 ) { + my @strings = ($&); + my $token; + $work = $'; + while($token = pop @tokens){ + if ( $token->string =~ m/\[%.*?$/s ) { + push @tokens, C4::TmplToken->new( $`, $token->type, $token->line_number, $token->pathname ); + push @strings, $&; + last; + } else { + push @strings, $token->string; + } + } + push @tokens, C4::TmplToken->new( join('', reverse @strings), C4::TmplTokenType::DIRECTIVE, $token ? $token->line_number : $line, $self->{filename} ); + } while($work){ # if there is a template_toolkit tag if( $work =~ m/\[%.*?%\]/ ){ -- 2.34.1