Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Commit

Permalink
bug #282 Twig 2.10 Deprecation Update to swiftmailer.html.twig (KrisC…
Browse files Browse the repository at this point in the history
…arr)

This PR was merged into the 3.2-dev branch.

Discussion
----------

Twig 2.10 Deprecation Update to swiftmailer.html.twig

This change addresses the following Twig deprecation:

> Adding an if condition on a for tag is deprecated in Twig 2.10. Use a filter filter or an "if" condition inside the "for" body instead (if your condition depends on a variable updated inside the loop). https://twig.symfony.com/doc/2.x/deprecated.html

This solution uses the "filter" filter to maintain the single-tag "for" previously in place over adding a separate "if" tag. This requires Twig 1.41 or higher. (https://twig.symfony.com/doc/2.x/filters/filter.html)

A solution that does not use "filter" can be found at #284

Commits
-------

ad98ef1 Update swiftmailer.html.twig
  • Loading branch information
fabpot committed May 11, 2019
2 parents 4c46b6d + ad98ef1 commit 7b34820
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Resources/views/Collector/swiftmailer.html.twig
Expand Up @@ -197,7 +197,7 @@
</div>
<div class="col">
<span class="label">Headers</span>
<pre class="prewrap">{% for header in message.headers.all if (header.fieldName ?? '') not in ['Subject', 'From', 'To'] %}
<pre class="prewrap">{% for header in message.headers.all|filter(header => (header.fieldName ?? '') not in ['Subject', 'From', 'To']) %}
{{- header -}}
{% endfor %}</pre>
</div>
Expand Down Expand Up @@ -230,7 +230,7 @@
</div>
</div>

{% for messagePart in message.children if messagePart.contentType in ['text/plain', 'text/html'] %}
{% for messagePart in message.children|filter(messagePart => messagePart.contentType in ['text/plain', 'text/html']) %}
<div class="card-block">
<span class="label">Alternative part ({{ messagePart.contentType }})</span>
<pre class="prewrap">
Expand Down

0 comments on commit 7b34820

Please sign in to comment.