Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix #6212 - basic support for multiple parameters on a flexy:foreach…

…="method(a,b,c),e,f"

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Template_Flexy/trunk@298682 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 68106eb3e693027bf2e9bce89bad869000e712f8 1 parent 723a7b8
Alan Knowles authored April 28, 2010
20  HTML/Template/Flexy/Compiler/Flexy/Tag.php
@@ -475,9 +475,25 @@ function parseAttributeForeach()
475 475
         
476 476
         $this->element->hasForeach = true;
477 477
         // create a foreach element to wrap this with.
478  
-        
  478
+        $foreachTokens = explode( ",", $foreach ); //usual
  479
+        $first = array_shift($foreachTokens);
  480
+        // we will accept first argument as a method call.. with arguments.
  481
+        // this however does not  deal with  '#' with commas and braces insed very weill..
  482
+        if (strpos($first, '(') !== false) {
  483
+            while (strpos($first, ')') === false) {
  484
+                if (!count($foreachTokens)) {
  485
+                    return $this->_raiseErrorWithPositionAndTag(
  486
+                        "Missing Closer on functin call: An flexy:foreach attribute was found. flexy:foreach=&quot;$foreach&quot;<BR>
  487
+                        the syntax is  &lt;sometag flexy:foreach=&quot;onarray,withvariable[,withanothervar] &gt;<BR>",
  488
+                        null,  HTML_TEMPLATE_FLEXY_ERROR_DIE);
  489
+                }
  490
+                $first .= ',' . array_shift($foreachTokens);
  491
+            }
  492
+        }
  493
+        array_unshift($foreachTokens, $first);
  494
+
479 495
         $foreachObj =  $this->element->factory('Foreach',
480  
-                explode(',',$foreach),
  496
+                $foreachTokens,
481 497
                 $this->element->line);
482 498
         // failed = probably not enough variables..    
483 499
         

0 notes on commit 68106eb

Please sign in to comment.
Something went wrong with that request. Please try again.