Browse Source

Merge pull request #716 from daylerees/feature/forelse-fix

Fix for @forelse only matching $vars.
Shawn McCool 12 years ago
parent
commit
23f469ae53
1 changed files with 2 additions and 2 deletions
  1. 2 2
      laravel/blade.php

+ 2 - 2
laravel/blade.php

@@ -213,12 +213,12 @@ class Blade {
 
 		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
 			// an if statement to the start of the loop that checks if the count
 			// 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*\(.*\))/';