8000 minor #45858 Use source() function to include assets in template (Gro… · symfony/symfony@1627e45 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1627e45

Browse files
committed
minor #45858 Use source() function to include assets in template (GromNaN)
This PR was merged into the 6.1 branch. Discussion ---------- Use source() function to include assets in template | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - - Use the `source()` function to include static assets. Avoids twig parsing and compilation and prevents eventual syntax error. - Replace `{% include %}` with `{{ include() }}` where remaining. Commits ------- ecc72ba Use source() function to include assets in template
2 parents 26c1d4b + ecc72ba commit 1627e45

26 files changed

+59
-59
lines changed

src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/dump.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block toolbar %}
44
{% if collector.dumpsCount %}
55
{% set icon %}
6-
{{ include('@Debug/Profiler/icon.svg') }}
6+
{{ source('@Debug/Profiler/icon.svg') }}
77
<span class="sf-toolbar-value">{{ collector.dumpsCount }}</span>
88
{% endset %}
99

@@ -35,7 +35,7 @@
3535

3636
{% block menu %}
3737
<span class="label {{ collector.dumpsCount == 0 ? 'disabled' }}">
38-
<span class="icon">{{ include('@Debug/Profiler/icon.svg') }}</span>
38+
<span class="icon">{{ source('@Debug/Profiler/icon.svg') }}</span>
3939
<strong>Debug</strong>
4040
</span>
4141
{% endblock %}

src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% block toolbar %}
66
{% if collector.firewall %}
77
{% set icon %}
8-
{{ include('@Security/Collector/icon.svg') }}
8+
{{ source('@Security/Collector/icon.svg') }}
99
<span class="sf-toolbar-value">{{ collector.user|default('n/a') }}</span>
1010
{% endset %}
1111

@@ -109,7 +109,7 @@
109109

110110
{% block menu %}
111111
<span class="label {{ not collector.firewall or not collector.token ? 'disabled' }}">
112-
<span class="icon">{{ include('@Security/Collector/icon.svg') }}</span>
112+
<span class="icon">{{ source('@Security/Collector/icon.svg') }}</span>
113113
<strong>Security</strong>
114114
</span>
115115
{% endblock %}
@@ -130,7 +130,7 @@
130130
</div>
131131

132132
<div class="metric">
133-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.authenticated ? 'yes' : 'no') ~ '.svg') }}</span>
133+
<span class="value">{{ source('@WebProfiler/Icon/' ~ (collector.authenticated ? 'yes' : 'no') ~ '.svg') }}</span>
134134
<span class="label">Authenticated</span>
135135
</div>
136136
</div>
@@ -187,11 +187,11 @@
187187
<span class="label">Name</span>
188188
</div>
189189
<div class="metric">
190-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.firewall.security_enabled ? 'yes' : 'no') ~ '.svg') }}</span>
190+
<span class="value">{{ source('@WebProfiler/Icon/' ~ (collector.firewall.security_enabled ? 'yes' : 'no') ~ '.svg') }}</span>
191191
<span class="label">Security enabled</span>
192192
</div>
193193
<div class="metric">
194-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.firewall.stateless ? 'yes' : 'no') ~ '.svg') }}</span>
194+
<span class="value">{{ source('@WebProfiler/Icon/' ~ (collector.firewall.stateless ? 'yes' : 'no') ~ '.svg') }}</span>
195195
<span class="label">Stateless</span>
196196
</div>
197197
</div>
@@ -310,7 +310,7 @@
310310

311311
<tr>
312312
<td class="font-normal">{{ profiler_dump(authenticator.stub) }}</td>
313-
<td class="no-wrap">{{ include('@WebProfiler/Icon/' ~ (authenticator.supports ? 'yes' : 'no') ~ '.svg') }}</td>
313+
<td class="no-wrap">{{ source('@WebProfiler/Icon/' ~ (authenticator.supports ? 'yes' : 'no') ~ '.svg') }}</td>
314314
<td class="no-wrap">{{ '%0.2f'|format(authenticator.duration * 1000) }} ms</td>
315315
<td class="font-normal">{{ authenticator.passport ? profiler_dump(authenticator.passport) : '(none)' }}</td>
316316
</tr>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/ajax.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{% block toolbar %}
44
{% set icon %}
5-
{{ include('@WebProfiler/Icon/ajax.svg') }}
5+
{{ source('@WebProfiler/Icon/ajax.svg') }}
66
<span class="sf-toolbar-value sf-toolbar-ajax-request-counter">0</span>
77
{% endset %}
88

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/cache.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block toolbar %}
44
{% if collector.totals.calls > 0 %}
55
{% set icon %}
6-
{{ include('@WebProfiler/Icon/cache.svg') }}
6+
{{ source('@WebProfiler/Icon/cache.svg') }}
77
<span class="sf-toolbar-value">{{ collector.totals.calls }}</span>
88
<span class="sf-toolbar-info-piece-additional-detail">
99
<span class="sf-toolbar-label">in</span>
@@ -37,7 +37,7 @@
3737
{% block menu %}
3838
<span class="label {{ collector.totals.calls == 0 ? 'disabled' }}">
3939
<span class="icon">
40-
{{ include('@WebProfiler/Icon/cache.svg') }}
40+
{{ source('@WebProfiler/Icon/cache.svg') }}
4141
</span>
4242
<strong>Cache</strong>
4343
</span>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
20 F438 20

2121
{% set icon %}
2222
<span class="sf-toolbar-label">
23-
{{ include('@WebProfiler/Icon/symfony.svg') }}
23+
{{ source('@WebProfiler/Icon/symfony.svg') }}
2424
</span>
2525
<span class="sf-toolbar-value">{{ collector.symfonyState is defined ? collector.symfonyversion : 'n/a' }}</span>
2626
{% endset %}
@@ -108,7 +108,7 @@
108108

109109
{% block menu %}
110110
<span class="label label-status-{{ collector.symfonyState == 'eol' ? 'red' : collector.symfonyState in ['eom', 'dev'] ? 'yellow' }}">
111-
<span class="icon">{{ include('@WebProfiler/Icon/config.svg') }}</span>
111+
<span class="icon">{{ source('@WebProfiler/Icon/config.svg') }}</span>
112112
<strong>Configuration</strong>
113113
</span>
114114
{% endblock %}
@@ -191,17 +191,17 @@
191191

192192
<div class="metrics">
193193
<div class="metric">
194-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
194+
<span class="value">{{ source('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
195195
<span class="label">OPcache</span>
196196
</div>
197197

198198
<div class="metric">
199-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no-gray') ~ '.svg') }}</span>
199+
<span class="value">{{ source('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no-gray') ~ '.svg') }}</span>
200200
<span class="label">APCu</span>
201201
</div>
202202

203203
<div class="metric">
204-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no-gray') ~ '.svg') }}</span>
204+
<span class="value">{{ source('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no-gray') ~ '.svg') }}</span>
205205
<span class="label">Xdebug</span>
206206
</div>
207207
</div>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% block menu %}
66
<span class="label">
7-
<span class="icon">{{ include('@WebProfiler/Icon/event.svg') }}</span>
7+
<span class="icon">{{ source('@WebProfiler/Icon/event.svg') }}</span>
88
<strong>Events</strong>
99
</span>
1010
{% endblock %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
{% block menu %}
1414
<span class="label {{ collector.hasexception ? 'label-status-error' : 'disabled' }}">
15-
<span class="icon">{{ include('@WebProfiler/Icon/exception.svg') }}</span>
15+
<span class="icon">{{ source('@WebProfiler/Icon/exception.svg') }}</span>
1616
<strong>Exception</strong>
1717
{% if collector.hasexception %}
1818
<span class="count">

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% if collector.data.nb_errors > 0 or collector.data.forms|length %}
77
{% set status_color = collector.data.nb_errors ? 'red' %}
88
{% set icon %}
9-
{{ include('@WebProfiler/Icon/form.svg') }}
9+
{{ source('@WebProfiler/Icon/form.svg') }}
1010
<span class="sf-toolbar-value">
1111
{{ collector.data.nb_errors ?: collector.data.forms|length }}
1212
</span>
@@ -29,7 +29,7 @@
2929

3030
{% block menu %}
3131
<span class="label label-status-{{ collector.data.nb_errors ? 'error' }} {{ collector.data.forms is empty ? 'disabled' }}">
32-
<span class="icon">{{ include('@WebProfiler/Icon/form.svg') }}</span>
32+
<span class="icon">{{ source('@WebProfiler/Icon/form.svg') }}</span>
3333
<strong>Forms</strong>
3434
{% if collector.data.nb_errors > 0 %}
3535
<span class="count">

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/http_client.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block toolbar %}
44
{% if collector.requestCount %}
55
{% set icon %}
6-
{{ include('@WebProfiler/Icon/http-client.svg') }}
6+
{{ source('@WebProfiler/Icon/http-client.svg') }}
77
{% set status_color = '' %}
88
<span class="sf-toolbar-value">{{ collector.requestCount }}</span>
99
{% endset %}
@@ -25,7 +25,7 @@
2525

2626
{% block menu %}
2727
<span class="label {{ collector.requestCount == 0 ? 'disabled' }}">
28-
<span class="icon">{{ include('@WebProfiler/Icon/http-client.svg') }}</span>
28+
<span class="icon">{{ source('@WebProfiler/Icon/http-client.svg') }}</span>
2929
<strong>HTTP Client</strong>
3030
{% if collector.requestCount %}
3131
<span class="count">

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% if collector.counterrors or collector.countdeprecations or collector.countwarnings %}
77
{% set icon %}
88
{% set status_color = collector.counterrors ? 'red' : collector.countwarnings ? 'yellow' : 'none' %}
9-
{{ include('@WebProfiler/Icon/logger.svg') }}
9+
{{ source('@WebProfiler/Icon/logger.svg') }}
1010
<span class="sf-toolbar-value">{{ collector.counterrors ?: (collector.countdeprecations + collector.countwarnings) }}</span>
1111
{% endset %}
1212

@@ -33,7 +33,7 @@
3333

3434
{% block menu %}
3535
<span class="label label-status-{{ collector.counterrors ? 'error' : collector.countwarnings ? 'warning' : 'none' }} {{ collector.logs is empty ? 'disabled' }}">
36-
<span class="icon">{{ include('@WebProfiler/Icon/logger.svg') }}</span>
36+
<span class="icon">{{ source('@WebProfiler/Icon/logger.svg') }}</span>
3737
<strong>Logs</strong>
3838
{% if collector.counterrors or collector.countdeprecations or collector.countwarnings %}
3939
<span class="count">
@@ -83,7 +83,7 @@
8383

8484
<details id="log-filter-priority" class="log-filter">
8585
<summary>
86-
<span class="icon">{{ include('@WebProfiler/Icon/filter.svg') }}</span>
86+
<span class="icon">{{ source('@WebProfiler/Icon/filter.svg') }}</span>
8787
Level (<span class="filter-active-num">{{ filters.priority|length - 1 }}</span>)
8888
</summary>
8989

@@ -104,7 +104,7 @@
104104

105105
<details id="log-filter-channel" class="log-filter">
106106
<summary>
107-
<span class="icon">{{ include('@WebProfiler/Icon/filter.svg') }}</span>
107+
<span class="icon">{{ source('@WebProfiler/Icon/filter.svg') }}</span>
108108
Channel (<span class="filter-active-num">{{ filters.channel|length - 1 }}</span>)
109109
</summary>
110110

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
{% if events.messages|length %}
77
{% set icon %}
8-
{% include('@WebProfiler/Icon/mailer.svg') %}
8+
{{ source('@WebProfiler/Icon/mailer.svg') }}
99
<span class="sf-toolbar-value">{{ events.messages|length }}</span>
1010
{% endset %}
1111

@@ -65,7 +65,7 @@
6565
{% set events = collector.events %}
6666

6767
<span class="label {{ events.messages is empty ? 'disabled' }}">
68-
<span class="icon">{{ include('@WebProfiler/Icon/mailer.svg') }}</span>
68+
<span class="icon">{{ source('@WebProfiler/Icon/mailer.svg') }}</span>
6969

7070
<strong>E-mails</strong>
7171
{% if events.messages|length > 0 %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block toolbar %}
44
{% set icon %}
55
{% set status_color = (collector.memory / 1024 / 1024) > 50 ? 'yellow' %}
6-
{{ include('@WebProfiler/Icon/memory.svg') }}
6+
{{ source('@WebProfiler/Icon/memory.svg') }}
77
<span class="sf-toolbar-value">{{ '%.1f'|format(collector.memory / 1024 / 1024) }}</span>
88
<span class="sf-toolbar-label">MiB</span>
99
{% endset %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/messenger.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% if collector.messages|length > 0 %}
77
{% set status_color = collector.exceptionsCount ? 'red' %}
88
{% set icon %}
9-
{{ include('@WebProfiler/Icon/messenger.svg') }}
9+
{{ source('@WebProfiler/Icon/messenger.svg') }}
1010
<span class="sf-toolbar-value">{{ collector.messages|length }}</span>
1111
{% endset %}
1212

@@ -31,7 +31,7 @@
3131

3232
{% block menu %}
3333
<span class="label{{ collector.exceptionsCount ? ' label-status-error' }}{{ collector.messages is empty ? ' disabled' }}">
34-
<span class="icon">{{ include('@WebProfiler/Icon/messenger.svg') }}</span>
34+
<span class="icon">{{ source('@WebProfiler/Icon/messenger.svg') }}</span>
3535
<strong>Messages</strong>
3636
{% if collector.exceptionsCount > 0 %}
3737
<span class="count">
@@ -119,8 +119,8 @@
119119
<span class="label status-error">exception</span>
120120
{% endif %}
121121
<a class="toggle-button">
122-
<span class="icon icon-close">{{ include('@WebProfiler/images/icon-minus-square.svg') }}</span>
123-
<span class="icon icon-open">{{ include('@WebProfiler/images/icon-plus-square.svg') }}</span>
122+
<span class="icon icon-close">{{ source('@WebProfiler/images/icon-minus-square.svg') }}</span>
123+
<span class="icon icon-open">{{ source('@WebProfiler/images/icon-plus-square.svg') }}</span>
124124
</a>
125125
</th>
126126
</tr>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
{% if events.messages|length %}
77
{% set icon %}
8-
{% include('@WebProfiler/Icon/notifier.svg') %}
8+
{{ source('@WebProfiler/Icon/notifier.svg') }}
99
<span class="sf-toolbar-value">{{ events.messages|length }}</span>
1010
{% endset %}
1111

@@ -68,7 +68,7 @@
6868
{% set events = collector.events %}
6969

7070
<span class="label {{ events.messages|length ? '' : 'disabled' }}">
71-
<span class="icon">{{ include('@WebProfiler/Icon/notifier.svg') }}</span>
71+
<span class="icon">{{ source('@WebProfiler/Icon/notifier.svg') }}</span>
7272

7373
<strong>Notifications</strong>
7474
{% if events.messages|length > 0 %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
{% set icon %}
2525
<span class="sf-t 10000 oolbar-status sf-toolbar-status-{{ request_status_code_color }}">{{ collector.statuscode }}</span>
2626
{% if collector.route %}
27-
{% if collector.redirect %}{{ include('@WebProfiler/Icon/redirect.svg') }}{% endif %}
28-
{% if collector.forwardtoken %}{{ include('@WebProfiler/Icon/forward.svg') }}{% endif %}
27+
{% if collector.redirect %}{{ source('@WebProfiler/Icon/redirect.svg') }}{% endif %}
28+
{% if collector.forwardtoken %}{{ source('@WebProfiler/Icon/forward.svg') }}{% endif %}
2929
<span class="sf-toolbar-label">{{ 'GET' != collector.method ? collector.method }} @</span>
3030
<span class="sf-toolbar-value sf-toolbar-info-piece-additional">{{ collector.route }}</span>
3131
{% endif %}
@@ -99,7 +99,7 @@
9999

100100
{% block menu %}
101101
<span class="label">
102-
<span class="icon">{{ include('@WebProfiler/Icon/request.svg') }}</span>
102+
<span class="icon">{{ source('@WebProfiler/Icon/request.svg') }}</span>
103103
<strong>Request / Response</strong>
104104
</span>
105105
{% endblock %}
@@ -265,7 +265,7 @@
265265
</div>
266266

267267
<div class="metric">
268-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.statelesscheck ? 'yes' : 'no') ~ '.svg') }}</span>
268+
<span class="value">{{ source('@WebProfiler/Icon/' ~ (collector.statelesscheck ? 'yes' : 'no') ~ '.svg') }}</span>
269269
<span class="label">Stateless check enabled</span>
270270
</div>
271271
</div>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% block menu %}
66
<span class="label">
7-
<span class="icon">{{ include('@WebProfiler/Icon/router.svg') }}</span>
7+
<span class="icon">{{ source('@WebProfiler/Icon/router.svg') }}</span>
88
<strong>Routing</strong>
99
</span>
1010
{% endblock %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{% set status_color = has_time_events and collector.duration > 1000 ? 'yellow' %}
1010

1111
{% set icon %}
12-
{{ include('@WebProfiler/Icon/time.svg') }}
12+
{{ source('@WebProfiler/Icon/time.svg') }}
1313
<span class="sf-toolbar-value">{{ total_time }}</span>
1414
<span class="sf-toolbar-label">ms</span>
1515
{% endset %}
@@ -30,7 +30,7 @@
3030

3131
{% block menu %}
3232
<span class="label">
33-
<span class="icon">{{ include('@WebProfiler/Icon/time.svg') }}</span>
33+
<span class="icon">{{ source('@WebProfiler/Icon/time.svg') }}</span>
3434
<strong>Performance</strong>
3535
</span>
3636
{% endblock %}
@@ -144,10 +144,10 @@
144144
</defs>
145145
</svg>
146146
<style type="text/css">
147-
{% include '@WebProfiler/Collector/time.css.twig' %}
147+
{{ include('@WebProfiler/Collector/time.css.twig') }}
148148
</style>
149149
<script>
150-
{% include '@WebProfiler/Collector/time.js' %}
150+
{{ source('@WebProfiler/Collector/time.js') }}
151151
</script>
152152
{% endblock %}
153153

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% block toolbar %}
66
{% if collector.messages|length %}
77
{% set icon %}
8-
{{ include('@WebProfiler/Icon/translation.svg') }}
8+
{{ source('@WebProfiler/Icon/translation.svg') }}
99
{% set status_color = collector.countMissings ? 'red' : collector.countFallbacks ? 'yellow' %}
1010
{% set error_count = collector.countMissings + collector.countFallbacks %}
1111
<span class="sf-toolbar-value">{{ error_count ?: collector.countDefines }}</span>
@@ -44,7 +44,7 @@
4444

4545
{% block menu %}
4646
<span class="label label-status-{{ collector.countMissings ? 'error' : collector.countFallbacks ? 'warning' }} {{ collector.messages is empty ? 'disabled' }}">
47-
<span class="icon">{{ include('@WebProfiler/Icon/translation.svg') }}</span>
47+
<span class="icon">{{ source('@WebProfiler/Icon/translation.svg') }}</span>
4848
<strong>Translation</strong>
4949
{% if collector.countMissings or collector.countFallbacks %}
5050
{% set error_count = collector.countMissings + collector.countFallbacks %}

0 commit comments

Comments
 (0)
0