Permalink
Browse files

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...
roojs committed Apr 28, 2010
1 parent 723a7b8 commit 68106eb3e693027bf2e9bce89bad869000e712f8
Showing with 18 additions and 2 deletions.
  1. +18 −2 HTML/Template/Flexy/Compiler/Flexy/Tag.php
@@ -475,9 +475,25 @@ function parseAttributeForeach()
$this->element->hasForeach = true;
// create a foreach element to wrap this with.
-
+ $foreachTokens = explode( ",", $foreach ); //usual
+ $first = array_shift($foreachTokens);
+ // we will accept first argument as a method call.. with arguments.
+ // this however does not deal with '#' with commas and braces insed very weill..
+ if (strpos($first, '(') !== false) {
+ while (strpos($first, ')') === false) {
+ if (!count($foreachTokens)) {
+ return $this->_raiseErrorWithPositionAndTag(
+ "Missing Closer on functin call: An flexy:foreach attribute was found. flexy:foreach=&quot;$foreach&quot;<BR>
+ the syntax is &lt;sometag flexy:foreach=&quot;onarray,withvariable[,withanothervar] &gt;<BR>",
+ null, HTML_TEMPLATE_FLEXY_ERROR_DIE);
+ }
+ $first .= ',' . array_shift($foreachTokens);
+ }
+ }
+ array_unshift($foreachTokens, $first);
+
$foreachObj = $this->element->factory('Foreach',
- explode(',',$foreach),
+ $foreachTokens,
$this->element->line);
// failed = probably not enough variables..

0 comments on commit 68106eb

Please sign in to comment.