8000 bug #25744 [TwigBridge] Allow label translation to be safe (MatTheCat) · symfony/symfony@c645335 · GitHub
[go: up one dir, main page]

Skip to content

Commit c645335

Browse files
committed
bug #25744 [TwigBridge] Allow label translation to be safe (MatTheCat)
This PR was merged into the 2.7 branch. Discussion ---------- [TwigBridge] Allow label translation to be safe | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | ~ | Fixed tickets | ~ | License | MIT | Doc PR | ~ After overriding `TranslationExtension`'s `trans` filter to make it safe I noticed form labels were still escaped because of `label` in ```twig {{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }} ``` Replacing this ternary with `if`/`else` allows `trans` return to be safe. WDYT? Commits ------- 041c42d Allow trans filter to be safe
2 parents 1ee3950 + 041c42d commit c645335

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@
219219
{% set label = name|humanize %}
220220
{%- endif -%}
221221
{%- endif -%}
222-
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}</label>
222+
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
223+
{%- if translation_domain is same as(false) -%}
224+
{{- label -}}
225+
{%- else -%}
226+
{{- label|trans({}, translation_domain) -}}
227+
{%- endif -%}
228+
</label>
223229
{%- endif -%}
224230
{%- endblock form_label -%}
225231

0 commit comments

Comments
 (0)
0