From f51fdc2b60899530e4e7f09f400891603b0d68dd Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 9 Aug 2010 17:33:36 +0200 Subject: [PATCH] =?utf8?q?Erm=C3=B6glichen,=20dass=20<%foreachrow%>=20in?= =?utf8?q?=20OpenDocument=20=C3=BCber=20mehrere=20Zeilen=20geht?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Hintergrund: Um Zwischenzummen zu ermöglichen, müss ein Konstrukt wie folgt genutzt werden: |<%foreachrow ...%>|<%description%>|...|<%linetotal%><%if discount_sub%>| | |Zwischensumme: |...|<%discount_sub%><%end%><%end%> | --- SL/Template/OpenDocument.pm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index 626d3c0bf..98fba0592 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -109,21 +109,27 @@ sub parse_block { $contents =~ m|^(.*?)(]*>)|; my $table_row = $1; my $end_tag = $2; - substr($contents, 0, length($1) + length($end_tag)) = ""; if ($table_row =~ m|\<\%foreachrow\s+(.*?)\%\>|) { my $var = $1; - substr($table_row, length($`), length($&)) = ""; + $contents =~ m|\<\%foreachrow\s+.*?\%\>|; + substr($contents, length($`), length($&)) = ""; - my ($t1, $t2) = $self->find_end($table_row, length($`)); - if (!$t1) { + ($table_row, $contents) = $self->find_end($contents, length($`)); + if (!$table_row) { $self->{"error"} = "Unclosed <\%foreachrow\%>." unless ($self->{"error"}); $main::lxdebug->leave_sub(); return undef; } - my $new_text = $self->parse_foreach($var, $t1 . $t2, $tag, $end_tag, @indices); + $contents =~ m|^(.*?)(]*>)|; + $table_row .= $1; + $end_tag = $2; + + substr $contents, 0, length($&), ''; + + my $new_text = $self->parse_foreach($var, $table_row, $tag, $end_tag, @indices); if (!defined($new_text)) { $main::lxdebug->leave_sub(); return undef; @@ -131,6 +137,7 @@ sub parse_block { $new_contents .= $new_text; } else { + substr($contents, 0, length($table_row) + length($end_tag)) = ""; my $new_text = $self->parse_block($table_row, @indices); if (!defined($new_text)) { $main::lxdebug->leave_sub(); -- 2.20.1