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!

https://craftcms.stackexchange.com/a/863/8942

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

Checking for paragraph.bundle type in node template https://www.drupal.org/project/paragraphs/issues/2925077

Very similar: https://drupal.stackexchange.com/questions/194358/getting-current-node-paragraphs-content-from-block

And see https://drupal.stackexchange.com/questions/186315/how-to-get-instance-of-referenced-entity 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 192.168.42.1:43236] 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’