Skip to content

Commit 702fe9c

Browse files
committed
minor #19774 [Twig] Expand the explanation about the humanize filter (javiereguiluz)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Twig] Expand the explanation about the humanize filter Fixes #19758. Commits ------- 7516215 [Twig] Expand the explanation about the humanize filter
2 parents 273581b + 7516215 commit 702fe9c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

reference/twig_reference.rst

+12-3
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,18 @@ humanize
391391
``text``
392392
**type**: ``string``
393393

394-
Makes a technical name human readable (i.e. replaces underscores by spaces
395-
or transforms camelCase text like ``helloWorld`` to ``hello world``
396-
and then capitalizes the string).
394+
Transforms the given string into a human readable string (by replacing underscores
395+
with spaces, capitalizing the string, etc.) It's useful e.g. when displaying
396+
the names of PHP properties/variables to end users:
397+
398+
.. code-block:: twig
399+
400+
{{ 'dateOfBirth'|humanize }} {# renders: Date of birth #}
401+
{{ 'DateOfBirth'|humanize }} {# renders: Date of birth #}
402+
{{ 'date-of-birth'|humanize }} {# renders: Date-of-birth #}
403+
{{ 'date_of_birth'|humanize }} {# renders: Date of birth #}
404+
{{ 'date of birth'|humanize }} {# renders: Date of birth #}
405+
{{ 'Date Of Birth'|humanize }} {# renders: Date of birth #}
397406
398407
.. _reference-twig-filter-trans:
399408

0 commit comments

Comments
 (0)