Sponsored Link

continue, break

continue/breakタグは、foreachタグの中でPHPのcontinue/break文のような動作をします。

Syntax

{{ @foreach val_name }}
    {{ @if operand operator operand }}
        {{ @continue }} | {{ @break }} | statements
    {{ @elseif operand operator operand }}
        {{ @continue }} | {{ @break }} | statements
    {{ @else }}
        {{ @continue }} | {{ @break }} | statements
    {{ @endif }}
{{ @endforeach }}

PHP

$assign['sample_foreach7']['a7'][] = array('id'=>71, 'name'=>'Windows', 'vendor'=>'MicroSoft');
$assign['sample_foreach7']['a7'][] = array('id'=>72, 'name'=>'MacOS', 'vendor'=>'Apple');
$assign['sample_foreach7']['a7'][] = array('id'=>73, 'name'=>'continue', 'vendor'=>'continue');
$assign['sample_foreach7']['a7'][] = array('id'=>74, 'name'=>'break', 'vendor'=>'break');
$assign['sample_foreach7']['a7'][] = array('id'=>75, 'name'=>'none', 'vendor'=>'none');

Template

{{ @foreach sample_foreach7.a7 }}
    {{ @if .id == 71 }}
        if<br>
          -- id={{ .id }}, name={{ .name }}, vendor={{ .vendor }}<br>
    {{ @elseif .id == 73 }}
        continue<br>
        {{ @continue }}<br>
          -- id={{ .id }}, name={{ .name }}, vendor={{ .vendor }}<br>
    {{ @elseif .id == 74 }}
        break<br>
        {{ @break }}<br>
          -- id={{ .id }}, name={{ .name }}, vendor={{ .vendor }}<br>
    {{ @else }}
        else<br>
          -- id={{ .id }}, name={{ .name }}, vendor={{ .vendor }}<br>
    {{ @endif }}
{{ @endforeach }}

Result

if
-- id=71, name=Windows, vendor=MicroSoft
else
-- id=72, name=MacOS, vendor=Apple
continue
break