Merge branch 'master' of ssh://git-grichardson@lx-office.linet-services.de/~/lx-offic...
[kivitendo-erp.git] / SL / Template / LaTeX.pm
index c515187..4bfef01 100644 (file)
@@ -55,7 +55,7 @@ sub parse_foreach {
 
   for (my $i = 0; $i < scalar(@{$ary}); $i++) {
     # do magic markers
-    $form->{"__first__"}   = $i == 1;
+    $form->{"__first__"}   = $i == 0;
     $form->{"__last__"}    = ($i + 1) == scalar(@{$ary});
     $form->{"__odd__"}     = (($i + 1) % 2) == 1;
     $form->{"__counter__"} = $i + 1;
@@ -132,7 +132,7 @@ sub find_end {
 
     my $keyword_pos = $pos - 1 + $tag_start_len;
 
-    if ((substr($text, $keyword_pos, 2) eq 'if') || (substr($text, $keyword_pos, 3) eq 'for')) {
+    if ((substr($text, $keyword_pos, 2) eq 'if') || (substr($text, $keyword_pos, 3) eq 'foreach')) {
       $depth++;
 
     } elsif ((substr($text, $keyword_pos, 4) eq 'else') && (1 == $depth)) {
@@ -264,7 +264,7 @@ sub _parse_config_lines {
     $comment_start = '\s*%';
   } elsif (ref $self eq 'SL::Template::HTML') {
     $comment_start = '\s*<!--';
-    $comment_end   = '>\s*';
+    $comment_end   = '(?:--)?>\s*';
   } else {
     $comment_start = '\s*\#';
   }
@@ -275,7 +275,7 @@ sub _parse_config_lines {
   while ($i < $num_lines) {
     my $line = $lines->[$i];
 
-    if ($line !~ m/^${comment_start}\s*config\s*:(.*)${comment_end}$/i) {
+    if ($line !~ m/^${comment_start}\s*config\s*:(.*?)${comment_end}$/i) {
       $i++;
       next;
     }