I want to use break in the Twig template engine.
{% for key, db_staff_language in db_staff_languages %}
{% for staff_language in model_data.staff_languages %}
{% if staff_language.id == db_staff_language.id %}
<option value="{{db_staff_language.id}}" selected="selected">{{db_staff_language.staff_languages_data_translation[0].value}}</option>
{% else %}
<option value="{{db_staff_language.id}}">{{db_staff_language.staff_languages_data_translation[0].value}}</option>
{% endif %}
{% break %} {# <-- Not working #}
{% endfor %}
{% endfor %}
As I couldn't solve the problem with Twig, I also tried other things, like:
-----------------------------------------------
{% autoescape true %}
<?php echo 'test' ?>
{% endautoescape %}
-----------------------------------------------
{% php %}
<?php echo 'test' ?>
{% endphp %}
-----------------------------------------------
{% verbatim %}
<?php echo "test"; ?>
{% endverbatim %}
-----------------------------------------------
{{ raw }}
<?php echo "test"; ?>
{{ endraw }}
-----------------------------------------------
Is there a solution for this problem?
Twig doesn't include a break statement. According to the official manual, the equivalent instruction is the for + if condition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With