Support the ongoing development of Laravel.io →
Views Blade
Last updated 2 years ago.
0

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

Last updated 2 years ago.
0
@foreach($rows as $row)
   <tr class="{{ ($n++%2) ? 'even' : 'odd' }}">
   </tr>
@endforeach
Last updated 2 years ago.
0
Last updated 2 years ago.
0

There is also a package for Smarty: https://packagist.org/packages/dark/smarty-view

Last updated 2 years ago.
0

Thanks for the replies. Nice alternatives. I will look into Twig. And I might even give Smarty a second chance :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

NLSurfMan nlsurfman Joined 14 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.