Skip to content

Commit 10db99e

Browse files
committed
minor #42010 Improve usage of twig ternary (Seb33300)
This PR was merged into the 4.4 branch. Discussion ---------- Improve usage of twig ternary | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | none | License | MIT | Doc PR | none Remove useless `else` condition when using twig ternary: > `{{ foo ? 'yes' }}` is the same as `{{ foo ? 'yes' : '' }}` See: https://twig.symfony.com/doc/3.x/templates.html#other-operators Commits ------- 4be962d323 Improve usage of twig ternary
2 parents 236017d + a7adf96 commit 10db99e

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

Resources/views/Collector/config.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
{% endblock %}
102102

103103
{% block menu %}
104-
<span class="label label-status-{{ collector.symfonyState == 'eol' ? 'red' : collector.symfonyState in ['eom', 'dev'] ? 'yellow' : '' }}">
104+
<span class="label label-status-{{ collector.symfonyState == 'eol' ? 'red' : collector.symfonyState in ['eom', 'dev'] ? 'yellow' }}">
105105
<span class="icon">{{ include('@WebProfiler/Icon/config.svg') }}</span>
106106
<strong>Configuration</strong>
107107
</span>

Resources/views/Collector/form.html.twig

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

55
{% block toolbar %}
66
{% if collector.data.nb_errors > 0 or collector.data.forms|length %}
7-
{% set status_color = collector.data.nb_errors ? 'red' : '' %}
7+
{% set status_color = collector.data.nb_errors ? 'red' %}
88
{% set icon %}
99
{{ include('@WebProfiler/Icon/form.svg') }}
1010
<span class="sf-toolbar-value">

Resources/views/Collector/logger.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@
201201

202202
<tbody>
203203
{% for log in logs %}
204-
{% set css_class = is_deprecation ? ''
205-
: log.priorityName in ['CRITICAL', 'ERROR', 'ALERT', 'EMERGENCY'] ? 'status-error'
204+
{% set css_class = not is_deprecation
205+
? log.priorityName in ['CRITICAL', 'ERROR', 'ALERT', 'EMERGENCY'] ? 'status-error'
206206
: log.priorityName == 'WARNING' ? 'status-warning'
207207
%}
208-
<tr class="{{ css_class }}"{% if show_level %} data-filter-level="{{ log.priorityName|lower }}"{% endif %}{% if channel_is_defined %} data-filter-channel="{{ log.channel is not null ? log.channel : '' }}"{% endif %}>
208+
<tr class="{{ css_class }}"{% if show_level %} data-filter-level="{{ log.priorityName|lower }}"{% endif %}{% if channel_is_defined %} data-filter-channel="{{ log.channel }}"{% endif %}>
209209
<td class="font-normal text-small" nowrap>
210210
{% if show_level %}
211211
<span class="colored text-bold">{{ log.priorityName }}</span>

Resources/views/Collector/mailer.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
{% block menu %}
6868
{% set events = collector.events %}
6969

70-
<span class="label {{ events.messages|length ? '' : 'disabled' }}">
70+
<span class="label {{ events.messages|empty ? 'disabled' }}">
7171
<span class="icon">{{ include('@WebProfiler/Icon/mailer.svg') }}</span>
7272

7373
<strong>E-mails</strong>

Resources/views/Collector/memory.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-
{% set status_color = (collector.memory / 1024 / 1024) > 50 ? 'yellow' : '' %}
5+
{% set status_color = (collector.memory / 1024 / 1024) > 50 ? 'yellow' %}
66
{{ include('@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>

Resources/views/Collector/time.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% set has_time_events = collector.events|length > 0 %}
77
{% set total_time = has_time_events ? '%.0f'|format(collector.duration) : 'n/a' %}
88
{% set initialization_time = collector.events|length ? '%.0f'|format(collector.inittime) : 'n/a' %}
9-
{% set status_color = has_time_events and collector.duration > 1000 ? 'yellow' : '' %}
9+
{% set status_color = has_time_events and collector.duration > 1000 ? 'yellow' %}
1010

1111
{% set icon %}
1212
{{ include('@WebProfiler/Icon/time.svg') }}

Resources/views/Collector/validator.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
{% if collector.violationsCount > 0 or collector.calls|length %}
5-
{% set status_color = collector.violationsCount ? 'red' : '' %}
5+
{% set status_color = collector.violationsCount ? 'red' %}
66
{% set icon %}
77
{{ include('@WebProfiler/Icon/validator.svg') }}
88
<span class="sf-toolbar-value">

Resources/views/Profiler/layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
{%- endif -%}
124124
{%- endset %}
125125
{% if menu is not empty %}
126-
<li class="{{ name }} {{ name == panel ? 'selected' : '' }}">
126+
<li class="{{ name }} {{ name == panel ? 'selected' }}">
127127
<a href="{{ path('_profiler', { token: token, panel: name }) }}">{{ menu|raw }}</a>
128128
</li>
129129
{% endif %}

0 commit comments

Comments
 (0)