8000 Deduplicated some code · symfony/swiftmailer-bundle@b3dd574 · GitHub
[go: up one dir, main page]

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

Commit b3dd574

Browse files
committed
Deduplicated some code
1 parent ae6b9f2 commit b3dd574

File tree

1 file changed

+66
-97
lines changed

1 file changed

+66
-97
lines changed

Resources/views/Collector/swiftmailer.html.twig

Lines changed: 66 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,26 @@
7070
{% set profiler_markup_version = profiler_markup_version|default(1) %}
7171

7272
{% if profiler_markup_version == 1 %}
73+
<style>
74+
h3 { margin-top: 2em; }
75+
h3 span { color: #999; font-weight: normal; }
76+
h3 small { color: #999; }
77+
h4 { font-size: 14px; font-weight: bold; }
78+
.card { background: #F5F5F5; margin: .5em 0 1em; padding: .5em; }
79+
.card .label { display: block; font-size: 13px; font-weight: bold; margin-bottom: .5em; }
80+
.card .card-block { margin-bottom: 1em; }
81+
</style>
82+
{% endif %}
83+
84+
<h2>E-mails</h2>
7385

74-
<h2>Messages</h2>
86+
{% if not collector.mailers %}
87+
<div class="empty">
88+
<p>No e-mail messages were sent.</p>
89+
</div>
90+
{% endif %}
7591

92+
{% if profiler_markup_version == 1 %}
7693
<table>
7794
<thead>
7895
<tr>
@@ -89,54 +106,7 @@
89106
{% endfor %}
90107
</tbody>
91108
</table>
92-
93-
{% for name in collector.mailers %}
94-
<h3>Mailer <em>{{ name }}</em>{{ collector.isDefaultMailer(name) ? ' (default mailer)' : '' }}</h3>
95-
96-
{% if not collector.messages(name) %}
97-
<p>
98-
<em>No message sent.</em>
99-
</p>
100-
{% else %}
101-
<ul class="alt">
102-
{% for message in collector.messages(name) %}
103-
<li class="{{ cycle(['odd', 'even'], loop.index) }}">
104-
{% for header in message.headers.all %}
105-
<pre>{{ header }}</pre>
106-
{% endfor %}
107-
<pre>
108-
{%- if messagePart.charset is defined and message.charset %}
109-
{{- message.body|e('html', message.charset)|convert_encoding('UTF-8', message.charset) }}
110-
{%- else %}
111-
{{- message.body|e('html') }}
112-
{%- endif -%}
113-
</pre>
114-
{% for messagePart in message.children if messagePart.contentType == 'text/plain' or messagePart.contentType == 'text/html' %}
115-
<h4>Alternative part</h4>
116-
<pre>
117-
{%- if messagePart.charset %}
118-
{{- messagePart.body|e('html', messagePart.charset)|convert_encoding('UTF-8', messagePart.charset) }}
119-
{%- else %}
120-
{{- messagePart.body|e('html') }}
121-
{%- endif -%}
122-
</pre>
123-
{% endfor %}
124-
</li>
125-
{% endfor %}
126-
</ul>
127-
{% endif %}
128-
{% endfor %}
129-
130109
{% else %}
131-
132-
<h2>E-mails</h2>
133-
134-
{% if not collector.mailers %}
135-
<div class="empty">
136-
<p>No e-mail messages were sent.</p>
137-
</div>
138-
{% endif %}
139-
140110
{% if collector.mailers|length > 1 %}
141111
<h3>Messages sent by each mailer</h3>
142112

@@ -168,62 +138,61 @@
168138
{% endfor %}
169139
</div>
170140
{% endif %}
141+
{% endif %}
171142

172-
{% for name in collector.mailers %}
173-
{% if collector.mailers|length > 1 %}
174-
<h3>
175-
{{ name }} <span>mailer</span>
176-
<small>{{ collector.isDefaultMailer(name) ? '(default app mailer)' }}</small>
177-
</h3>
178-
{% endif %}
143+
{% for name in collector.mailers %}
144+
{% if collector.mailers|length > 1 %}
145+
<h3>
146+
{{ name }} <span>mailer</span>
147+
<small>{{ collector.isDefaultMailer(name) ? '(default app mailer)' }}</small>
148+
</h3>
149+
{% endif %}
179150

180-
{% if not collector.messages(name) %}
181-
<div class="empty">
182-
<p>No e-mail messages were sent.</p>
183-
</div>
184-
{% else %}
185-
{% for message in collector.messages(name) %}
186-
{% if collector.messages(name)|length > 1 %}
187-
<h4>E-mail #{{ loop.index }} details</h4>
188-
{% else %}
189-
<h4>E-mail details</h4>
190-
{% endif %}
191-
192-
<div class="card">
193-
<div class="card-block">
194-
<span class="label">Message headers</span>
195-
<pre>{% for header in message.headers.all %}
196-
{{- header -}}
197-
{% endfor %}</pre>
198-
</div>
151+
{% if not collector.messages(name) %}
152+
<div class="empty">
153+
<p>No e-mail messages were sent.</p>
154+
</div>
155+
{% else %}
156+
{% for message in collector.messages(name) %}
157+
{% if collector.messages(name)|length > 1 %}
158+
<h4>E-mail #{{ loop.index }} details</h4>
159+
{% else %}
160+
<h4>E-mail details</h4>
161+
{% endif %}
162+
163+
<div class="card">
164+
<div class="card-block">
165+
<span class="label">Message headers</span>
166+
<pre>{% for header in message.headers.all %}
167+
{{- header -}}
168+
{% endfor %}</pre>
169+
</div>
199170

171+
<div class="card-block">
172+
<span class="label">Message body</span>
173+
<pre>
174+
{%- if messagePart.charset is defined and message.charset %}
175+
{{- message.body|e('html', message.charset)|convert_encoding('UTF-8', message.charset) }}
176+
{%- else %}
177+
{{- message.body|e('html') }}
178+
{%- endif -%}
179+
</pre>
180+
</div>
181+
182+
{% for messagePart in message.children if messagePart.contentType == 'text/plain' or messagePart.contentType == 'text/html' %}
200183
<div class="card-block">
201-
<span class="label">Message body</span>
184+
<span class="label">Alternative part ({{ messagePart.contentType }})</span>
202185
<pre>
203-
{%- if messagePart.charset is defined and message.charset %}
204-
{{- message.body|e('html', message.charset)|convert_encoding('UTF-8', message.charset) }}
186+
{%- if messagePart.charset %}
187+
{{- messagePart.body|e('html', messagePart.charset)|convert_encoding('UTF-8', messagePart.charset) }}
205188
{%- else %}
206-
{{- message.body|e('html') }}
189+
{{- messagePart.body|e('html') }}
207190
{%- endif -%}
208191
</pre>
209192
</div>
210-
211-
{% for messagePart in message.children if messagePart.contentType == 'text/plain' or messagePart.contentType == 'text/html' %}
212-
<div class="card-block">
213-
<span class="label">Alternative part ({{ messagePart.contentType }})</span>
214-
<pre>
215-
{%- if messagePart.charset %}
216-
{{- messagePart.body|e('html', messagePart.charset)|convert_encoding('UTF-8', messagePart.charset) }}
217-
{%- else %}
218-
{{- messagePart.body|e('html') }}
219-
{%- endif -%}
220-
</pre>
221-
</div>
222-
{% endfor %}
223-
</div>
224-
{% endfor %}
225-
{% endif %}
226-
{% endfor %}
227-
228-
{% endif %}
193+
{% endfor %}
194+
</div>
195+
{% endfor %}
196+
{% endif %}
197+
{% endfo 3582 r %}
229198
{% endblock %}

0 commit comments

Comments
 (0)
0