diff --git a/src/Fenom/Template.php b/src/Fenom/Template.php index f67cb78..c606773 100644 --- a/src/Fenom/Template.php +++ b/src/Fenom/Template.php @@ -644,7 +644,11 @@ class Template extends Render { } else { break; } - } else { + + } elseif($tokens->is('[')) { + $_exp .= $this->parseArray($tokens); + + } else { break; } } @@ -1126,11 +1130,7 @@ class Template extends Render { } if($tokens->is("=")) { $tokens->next(); - if ($tokens->is('[')) { - $params[ $key ] = $this->parseArray($tokens); - } else { - $params[ $key ] = $this->parseExp($tokens); - } + $params[ $key ] = $this->parseExp($tokens); } else { $params[ $key ] = 'true'; } diff --git a/tests/cases/Fenom/FunctionsTest.php b/tests/cases/Fenom/FunctionsTest.php index 888a40b..755a1e0 100644 --- a/tests/cases/Fenom/FunctionsTest.php +++ b/tests/cases/Fenom/FunctionsTest.php @@ -29,7 +29,8 @@ class FunctionsTest extends TestCase { $this->tpl('function_default_param_empty_array.tpl', '{sum}'); $this->tpl('function_default_param_const.tpl', '{inc a=1}'); $this->tpl('function_array_param.tpl', '{sum of=[1, 2, 3, 4, 5]}'); - } + $this->tpl('function_array_param_pos.tpl', '{sum [1, 2, 3, 4, 5]}'); + } public function testFunctionWithParams() { $output = $this->fenom->fetch('function_params_scalar.tpl'); @@ -56,9 +57,14 @@ class FunctionsTest extends TestCase { $this->assertEquals('2', $output); } - public function testFunctionWithArrayParam() { + public function testFunctionWithArrayNamedParam() { $output = $this->fenom->fetch('function_array_param.tpl'); $this->assertEquals('15', $output); } + public function testFunctionWithArrayPositionalParam() { + $output = $this->fenom->fetch('function_array_param_pos.tpl'); + $this->assertEquals('15', $output); + } + }