I have the following (Symfony 2) PHP Template:
<?php
$messages = $view['session']->getFlashes();
if (count($messages) > 0) : ?>
<section id="flashMessages">
<ul>
<?php foreach ($messages as $key => $msg) : ?>
<li class="<?php $key ?>">
<?php echo $msg ?>
</li>
<?php endforeach; ?>
</ul>
</section>
<?php endif; ?>
I want to convert to twig in a simple way. How can I do that? Can I even count() in twig? In twig, theres the else in the for loop but I want the section#flashMessages to show only if there are flash messages
Sorry, written right here — have no time to test it. But this should be good enough to show you the concepts.