Break a for loop in Twig

The motivation of course is to reduce unnecessary code processing.

Of course, it’s also almost certainly an indication that you need to move some logic out of the template layer and into code proper.

But there does seem to be a way!

Reason was this; doing it in code is sort of shown here:

Checking for paragraph.bundle type in node template

Very similar:

And see for part of how to do it properly in code (rather than in templates, which appear to only be able to parallel the alternate, not-as-recommended approach there)

[Wed Oct 24 22:06:36.559328 2018] [proxy_fcgi:error] [pid 14071:tid 140598220642048] [client] AH01071: Got error ‘PHP message: Uncaught PHP Exception Exception: “Object of type Drupal\Core\Field\EntityReferenceFieldItemList cannot be printed.” at /var/www/drutopia/web/core/lib/Drupal/Core/Template/TwigExtension.php line 465\n’