fix for forelse only matching $vars

Signed-off-by: Dayle Rees <thepunkfan@gmail.com>
This commit is contained in:
Dayle Rees 2012-05-25 20:34:13 +01:00
parent 34919aff71
commit 992a5f74ca
1 changed files with 2 additions and 2 deletions

View File

@ -213,12 +213,12 @@ protected static function compile_forelse($value)
foreach ($matches[0] as $forelse) foreach ($matches[0] as $forelse)
{ {
preg_match('/\$[^\s]*/', $forelse, $variable); preg_match('/\s*\(\s*(\S*)\s/', $forelse, $variable);
// Once we have extracted the variable being looped against, we can add // Once we have extracted the variable being looped against, we can add
// an if statement to the start of the loop that checks if the count // an if statement to the start of the loop that checks if the count
// of the variable being looped against is greater than zero. // of the variable being looped against is greater than zero.
$if = "<?php if (count({$variable[0]}) > 0): ?>"; $if = "<?php if (count({$variable[1]}) > 0): ?>";
$search = '/(\s*)@forelse(\s*\(.*\))/'; $search = '/(\s*)@forelse(\s*\(.*\))/';