Skip to content

Commit

Permalink
minor #42010 Improve usage of twig ternary (Seb33300)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed Jul 24, 2021
2 parents 73c7de5 + 88e23e1 commit 49a0906
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Resources/views/Collector/security.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{% block toolbar %}
{% if collector.token %}
{% set is_authenticated = collector.enabled and collector.authenticated %}
{% set color_code = is_authenticated ? '' : 'yellow' %}
{% set color_code = not is_authenticated ? 'yellow' %}
{% else %}
{% set color_code = collector.enabled ? 'red' : '' %}
{% set color_code = collector.enabled ? 'red' %}
{% endif %}

{% set icon %}
Expand Down

0 comments on commit 49a0906

Please sign in to comment.