Reputation: 1
Controller:
$app->get('/', function() use($app){
$feeds[0] = "test";
$feeds['name'] = "name";
$app->render('home.twig', $feeds);
})->name('home');
Twig:
<h2>
{% if feeds %}
{{ feeds[0] }}
{{ feeds.name }}
{% else %}
<h2 style="color: white">TEST</h2>
{% endif %}
</h2>
It displays TEST instead of the array that I used. When I try to var_dump it, the array contains the data yet it shows as empty in Twig.
Upvotes: 0
Views: 74
Reputation: 7408
Use this instead:
$app->render('home.twig', array('feed' => $feeds));
Upvotes: 5