The nice thing about blade is you can always use php (untested)...
<?php
$n = 0;
foreach($myrows as $myrow): $n++;?>
<tr class="<?php echo ($n%2) ? 'odd' : 'even' ?>">
</tr>
<?php endforeach;?>
We have legacy stuff in smarty and we can't wait to get away from it...
Custom macros may be worth looking at to replicate smarty plugins
@foreach($rows as $row)
<tr class="{{ ($n++%2) ? 'even' : 'odd' }}">
</tr>
@endforeach
Or use Twig, easy to use with a twig bridge (https://github.com/barryvdh/laravel-twigbridge) See http://twig.sensiolabs.org/doc/functions/cycle.html
There is also a package for Smarty: https://packagist.org/packages/dark/smarty-view
Thanks for the replies. Nice alternatives. I will look into Twig. And I might even give Smarty a second chance :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community