我正在尝试将routes.php
中的值数组传递到Blade模板中的@foreach
循环。这是我的路由例程:
Route::get('/', function()
{
$theColors = array("red","green","blue","yellow");
return View::make('hello', array('theLocation' => 'NYC', 'theWeather'=> 'stormy', 'theColors'));
});
以下是我的 Blade 模板代码:
@foreach ($theColors as $color)
<p>The color is {{$color}}.</p>
@endforeach
我的日志显示模板中的变量$theColors
没有被定义。我做错了什么?