{foreach $data as $item} {if $item@first || $item@index eq 3} first {/if} {if $item@last || $item@index eq 2} last {/if} {/foreach}